SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 
Python basics
Python basicsPython basics
Python basics
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Python set
Python setPython set
Python set
 
Python list
Python listPython list
Python list
 
Python ppt
Python pptPython ppt
Python ppt
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Python
PythonPython
Python
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
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 strings
Python stringsPython strings
Python strings
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Unit 2 python
Unit 2 pythonUnit 2 python
Unit 2 python
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Python Lambda Function
Python Lambda FunctionPython Lambda Function
Python Lambda Function
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 

Destacado

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
 

Destacado (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
 

Similar a Print input-presentation

Similar 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
 
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
 
Programada chapter 4
Programada chapter 4Programada chapter 4
Programada chapter 4
 

Último

Último (20)

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 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
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
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 

Print input-presentation