Input & Type Conversion in Python
Chapter 5: Input & Type Conversion
4 short lessons, with 3D animations, quizzes and coding tasks.
The lessons
Asking questions with input()
input() shows a prompt, waits for the user to type a line and press Enter, and gives back what they typed as a str.
Changing types: int(), float() and str()
int(), float() and str() build a new value of another type from the value you give them, if it can be read that way.
Numbers from input()
int(input(...)) asks a question and turns the answer into a number straight away, because Python works from the inside out.
True or False? bool() and truthiness
bool() turns any value into True or False: empty or zero is False, and everything else is True.