Input and Output
Getting Input
• To prompt the user for some information? Use the
input()
function
• The input function always returns a string (
str
)
>>> answer = input(
"What is your name? "
)
What is your name? I... I do not know that.
>>> answer
'I... I do not know that.'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Displaying Output
• Use the
print()
function to display output to the user
>>> qty =
2
>>>
print
(
"I have"
, qty,
"coconuts"
)
'I have 2 coconuts'
Index