livepython.net
CHAPTER 07Getting Input from the User
7.4  PRACTICE

Python Input Practice Questions for Beginners

Chapter 7 Recap and Practice

Your programs can now listen to the user. Here is the chapter in one table:

You writeIt does
name = input()reads one line the user types, as text
input("Name: ")shows a prompt first (it's printed into the output)
two input() callsread two lines, in order; too few lines gives EOFError
int(input())reads a whole number
float(input())reads a number that may have decimals
int("2.5"), int("ten")ValueError: the text isn't a whole number
input, process, outputread the values, work with them, show the result

On LivePython, type the answers in the Input box before the code runs, one per line.

Practice questions

In every question, use input() with no prompt text. The tests type several different inputs for you, so a program that only prints one fixed answer won't pass.

input()

  1. 51.Python Program to Greet the User by NameEasySolve
  2. 52.Python Program to Read Two Words and Make a SentenceEasySolve

Converting input

  1. 53.Python Program to Add Two Numbers from InputEasySolve
  2. 54.Python Program to Find a Rectangle's Area from InputEasySolve
  3. 55.Python Program to Convert Celsius to Fahrenheit from InputMediumSolve

Interactive programs

  1. 56.Python Program to Calculate Age in MonthsEasySolve
  2. 57.Python Program to Split a Bill Between FriendsMediumSolve
  3. 58.Python Program to Make a Shopping Receipt from InputHardSolve

Input, process, output: now your programs work for any user. Next, they'll make decisions with if.