Input
Last updated
Last updated
Typically, programs take input from a user, process this input and give the user output.
The input() function takes input from your console. It reads the input and converts it to a string.
Function
Converts
Example
int()
converts to an integer
num = int(input("Give me an integer: "))
float()
converts to a float
num = float(input("Give me a float: "))
When using the input function, think about about what data type you want.
A common mistake is not matching the number of open parenthesis and closed parenthesis.
Write a program that prompts for two numbers. Print the sum, difference, product, and quotient of those numbers. In addition, print the result of integer division and the modulus operator of those numbers.