Learning to Program in Python for Kids

of all ages  by Philip M Russell

Python Input

A times table program using input

Inputting information into the computer

Running programs is ok but they do the same thing each time. In some ways this is good, but to be really useful the computer needs input.

Let us consider the ways of entering information

counter = 1

This sets counter to hold a value


The input statement allows us to enter different information each time the program is run.

age = int(input (" What is your age? "))

The int() turns the text from the keyboard into an integer that we can work with. If we only want text we can omit this
age = input (" What is your age? ")

We start with a variable in this case age and after the input statement we ask a question.
What is your age?
Input statement code
The program looks and runs better if we put a space after the question mark and before the quote.
Running the input statement

When we type in an age now the text looks better presented.

Once the number is added then hit the enter or return key and this number is put into the age variable as the program is running.

Pi Python Character When we ask the program to print out the answer - the value of age - then what ever you typed in is what is displayed.

Now to get you to do some work.

Write me a program do do any times table you wish
Get the program to ask you which times table 
The get the program to ask you how many
Then use a loop and a sum to display it.

The answer is in the first screen dump at the top of this page.

There is another input command input_raw()