Programming fundamentalsLesson 2 of 6 in the course Statements

Python Input and Output with print() and input()

5 flashcards · 5 quiz questions · 5 match pairs · 5 fill-in sentences · English

Lesson progress
0 / 5

Your progress is kept in this browser only.Sign up to save it

Summary

Programs communicate with users by displaying information and receiving responses. In Python, the print() function displays output, while the input() function obtains input from the user.

Output is information or a result produced by a program. The print() function displays output to the user.

print("Today is Monday.") print("I like string beans.")

All flashcards

What is output in a program?
Output is information or a result produced by a program and displayed to the user.
What does `print()` do by default at the end of a call?
It adds a newline character, so subsequent output normally begins on the next line.
What are `sep` and `end` used for?
`sep` changes what appears between multiple values printed in one call. `end` changes what appears at the end of that call.
What does `input()` do, and what does it return?
`input()` reads one line entered by the user. The entered value is returned as text and can be assigned to a variable.
What is the purpose of a prompt in an `input()` statement?
A prompt is an optional message displayed to indicate what the user should enter before the program waits for input.

Quiz questions

  1. Which Python function displays output to the user?Answer: `print()`
  2. What does `print()` normally add after its output?Answer: A newline character
  3. What does the `sep` option customize in a `print()` call?Answer: The text placed between multiple values
  4. What happens when a `print()` call uses `end=""`?Answer: The call adds no ending text, so later output can continue on the same line.
  5. How much user input does one call to `input()` read?Answer: One line

Based on Introduction to Python Programming by Udayan Das, Aubrey Lawson, Chris Mayfield, Narges Norouzi (OpenStax), licensed CC BY 4.0. Adapted into a summary, flashcards and quizzes.

All Programming fundamentals lessons