SlideShare uma empresa Scribd logo
1 de 45
Input and print
in Python
Input strings
and numbers
Printing different
types of data
Simple
formatting
Input prompt
Hello
World!
print()
The print function displays
information to the user
Code
Result
print('Hello World')
Code
Result
print('Hello World')
print function
displays the text
Code
Result
print('Hello World')
Text included in
quote marks
Run the
code
Code
Result
print('Hello World')
Hello World
The print function
displays the text
Hello
World!
Printing different
types of data
Simple
formatting
Input prompt
Input strings
and numbers
input()
The input function accepts
information from the user
Code
Result
s = input('What day is it?')
print(s)
Code
Result
s = input('What day is it?')
print(s)
input function gets
information from the
user
Code
Result
s = input('What day is it?')
print(s)
This is the question
(prompt) to ask the user
Code
Result
s = input('What day is it?')
print(s)
The response is
stored in variable s
Run the
code
Code
Result
s = input('What day is it?')
print(s)
The input function
displays the
prompt
What day is it?
Code
Result
s = input('What day is it?')
print(s)
The user types in
a response
What day is it?
Tuesday
Code
Result
s = input('What day is it?')
print(s)
The print function
displays the result
What day is it?
Tuesday
Tuesday
Asking the user for a number
Code
Result
s = input('What is the year?')
y = int(s)
print(y)
Code
Result
s = input('What is the year?')
y = int(s)
print(y)
input function gets
information from the
user
Code
Result
s = input('What is the year?')
y = int(s)
print(y) The int function
converts the string s
into a number y
Run the
code
Code
Result
s = input('What is the year?')
y = int(s)
print(y)
The input function
displays the
prompt
What is the year?
Code
Result
s = input('What is the year?')
y = int(s)
print(y)
User types in a string
which represents a
number
What is the year?
1066
Code
Result
s = input('What is the year?')
y = int(s)
print(y) The int function
converts the string
to a number
What is the year?
1066
1066 print displays it
Printing different
types of data
Hello
World!
Input strings
and numbers
Simple
formatting
Input prompt
Code
Result
x = 'string data'
print(x)
string data
Code
Result
x = 2 + 3
print(x)
5
Code
Result
x = 0.5 * 3.0
print(x)
1.5
Code
Result
x = datetime.now()
print(x)
2016-01-07 17:37:01.368503
Hello
World!
Input strings
and numbers
Input prompt
Printing different
types of data
Simple
formatting
Code
Result
print(1)
print(2)
print(3)
1
2
3
Each output starts
on a new line
Several
separate print
statements
Code
Result
print('abc')
print()
print('def')
abc
def
Blank line
Empty print
statement
Code
Result
print(1, 2, 3)
1 2 3
Each item
separated by
a space
Several items
in one print
statement
Code
Result
print(1, 2, 3, sep='.')
1.2.3
Each item
separated by
a dot
Using the sep
parameter
Code
Result
print(1, 2, 3, sep='')
123
Items are not
separated
Using the sep
parameter with
and empty string
s = 'abc'
empty = ''
Two quotes characters
with no other characters
between them
Code
Result
print(1, end='')
print(2, end='')
print(3)
123 Each item is printed on
the same line
Using the end
parameter
Hello
World!
Input strings
and numbers
Simple
formatting
Printing different
types of data
Input prompt
The input prompt doesn't
have to be a question
Code
Result
s = input('>')
>
Code
Result
s = input()
Code
Result
print('You are in the haunted library. There')
print('is a book of spells on the table.')
s = input()
You are in the haunted library. There
is a book of spells on the table.
schoolcoders.com
@schoolcoders
Copyright Axlesoft Ltd 2015

Mais conteúdo relacionado

Mais procurados

Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
Laxman Puri
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 

Mais procurados (20)

Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Python programming
Python  programmingPython  programming
Python programming
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Python ppt
Python pptPython ppt
Python ppt
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python Collections Tutorial | Edureka
Python Collections Tutorial | EdurekaPython Collections Tutorial | Edureka
Python Collections Tutorial | Edureka
 
Inline function
Inline functionInline function
Inline function
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Python list
Python listPython list
Python list
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Python
PythonPython
Python
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 

Destaque

4. python functions
4. python   functions4. python   functions
4. python functions
in4400
 
Functions in python
Functions in pythonFunctions in python
Functions in python
Ilian Iliev
 
singh santosh-cv banking (1)
singh santosh-cv banking (1)singh santosh-cv banking (1)
singh santosh-cv banking (1)
Santosh Singh
 

Destaque (19)

Чи достатньо кафе, ресторанів, пабів у м. Запоріжжя?
Чи достатньо кафе, ресторанів, пабів у м. Запоріжжя?Чи достатньо кафе, ресторанів, пабів у м. Запоріжжя?
Чи достатньо кафе, ресторанів, пабів у м. Запоріжжя?
 
Python workbook olivieri
Python workbook olivieriPython workbook olivieri
Python workbook olivieri
 
Functions in python
Functions in python Functions in python
Functions in python
 
Day2
Day2Day2
Day2
 
Functions
FunctionsFunctions
Functions
 
python Function
python Function python Function
python Function
 
Python Functions (PyAtl Beginners Night)
Python Functions (PyAtl Beginners Night)Python Functions (PyAtl Beginners Night)
Python Functions (PyAtl Beginners Night)
 
Input and Output
Input and OutputInput and Output
Input and Output
 
Python datatype
Python datatypePython datatype
Python datatype
 
4. python functions
4. python   functions4. python   functions
4. python functions
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Function arguments In Python
Function arguments In PythonFunction arguments In Python
Function arguments In Python
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
singh santosh-cv banking (1)
singh santosh-cv banking (1)singh santosh-cv banking (1)
singh santosh-cv banking (1)
 
Dayana
DayanaDayana
Dayana
 
Products for Printing various Stationeries
Products for Printing various StationeriesProducts for Printing various Stationeries
Products for Printing various Stationeries
 
BIN2MAT user manual
BIN2MAT user manualBIN2MAT user manual
BIN2MAT user manual
 

Semelhante a Print input-presentation

Semelhante a Print input-presentation (20)

Learning to code with Python! (Microsoft Virtual Academy).pptx
Learning to code with Python! (Microsoft Virtual Academy).pptxLearning to code with Python! (Microsoft Virtual Academy).pptx
Learning to code with Python! (Microsoft Virtual Academy).pptx
 
Learning to code with Python! (MVA).pptx
Learning to code with Python! (MVA).pptxLearning to code with Python! (MVA).pptx
Learning to code with Python! (MVA).pptx
 
Python basics
Python basicsPython basics
Python basics
 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
 
1-Object and Data Structures.pptx
1-Object and Data Structures.pptx1-Object and Data Structures.pptx
1-Object and Data Structures.pptx
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Java script
Java scriptJava script
Java script
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptx
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 
Introduction to typescript
Introduction to typescriptIntroduction to typescript
Introduction to typescript
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
Char word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECTChar word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECT
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
C#.net
C#.netC#.net
C#.net
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 

Último

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 

Print input-presentation