next up previous
Next: Python variable types Up: A Second Python Program: Previous: The real code

Explanation of the program

The program consists of several statements. The statements are executed in the order in which they appear, starting from the first.

  name = input("Enter your name ")

Python has lots of built in functions. The input function reads one line from Unix standard input (the keyboard here) as a string of characters and stores the result, in this example, in the variable name. You can tell it is a function because the name input is followed immediately by a pair of parentheses (). The string inside the parentheses is printed on the screen. You can also omit the string, in which case nothing is printed.

  print("Your name is", name, "and your age is", age)

Notice that you can print a list of items by separating them with commas. Python's print function automatically inserts a space between them and ends the line neatly.

Carleton DeTar 2017-08-10