07 Print and Input
07 Print and Input
Online Course
Supported by
* All copyrights belong to UNESCO UNITWIN and it is prohibited to use these educational materials including the video and other
relevant materials for commercial and for-profit use.
Print and Input
07
Global Leadership School
Handong Global University
Learning Objectives
• Use print()
• Use input() with variables
• Practice Input/Output with exercise questions
Output to Screen
• print()
• Statement used to print (output)
• Used to print a string, numbers, and expressions
• Can print without print() statement in interactive
mode
Output to Screen, Example
>>> print(“John”)
John
>>> name = “John”
>>> print(“Hello,” name)
Hello John
>>> score = 78
>>> print(score)
78
>>> print(“name” , name, “score”, score)
name John score 78
>>> print( “abba” * 3)
abbaabbaabba
Output to Screen, Example
i=100
j=3
print(i+j)
i=i+100
print(“score is “, i)
twinkle = '*'
print(twinkle * 10)
Different examples
• Print expressions
• Use variables
Input from Screen
• Input()
• Used to receive input from users
• The input is read in as a string
• Need variable to store input data
• Example below uses the variable name “height”
Using Input and Output
• Input/print statements are always used
• Input and print statements are used together
>>> KKKKK
>>> IIIII
>>> MMMMM
Exercise 2, Code
## Split name and print
print( name[0] * 5 )
print( name[1] * 5 )
print( name[2] * 5 )
Exercise 3
• Receive name, institution, and year of birth
from the user
• Print name and institution and calculate the
age in 2019
Exercise 3, Code and output
## Print name, institution, and age
rest=int(belong)-int(cost)
* All copyrights belong to UNESCO UNITWIN and it is prohibited to use these educational
materials including the video and other relevant materials for commercial and for-profit use.
CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik.