Title: Keyboard Input
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

Python keyboard input:

- Is another way to place a value into a variable.
- By default, the data type of the value read from the keyboard is a string.
- If a numeric value is required, the methods int() and float() may be used to convert a string to a whole number or real number, respectively.

Keyboard input statement syntax:

<string-variable> = input(<prompt>)  # read into 'str' variable
<integer-variable> = int(input(<prompt>))  # read into 'int' variable
<real-number-variable> = float(input(<prompt>))  # read into 'float' variable

Keyboard input statement examples:

N = input("Enter a first name: ")
I = int(input("Enter a whole number: "))
R = float(input("Enter a real number: "))