0% found this document useful (0 votes)
11 views1 page

Python User Input CheatSheet

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Python User Input CheatSheet

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

■■ Python User Input Cheat Sheet

In Python, the input() function is used to get input from the user. The input is always returned as a
string.

Usage Description Example

input("Prompt") Shows prompt and waits for user input name = input("What is your name? ")
int(input()) Get number input as integer age = int(input("Enter your age: "))
float(input()) Get decimal input price = float(input("Enter price: "))
str(input()) Get input as string (optional, default) city = str(input("City? "))

Example:
name = input("What's your name? ") print("Hello, " + name) age = int(input("How old are you? "))
print("In 5 years, you'll be", age + 5)

You might also like