Module 2 · Python data types, variables, operators, and basic I/O operations
Interaction with the user
Until now your programs only spoke. Now they listen: read what the user types with input(), and turn that text into numbers you can compute with.
Begin lesson 1 →- 1The input() functionPause the program and read a line the user types — with a prompt.→
- 2The result is always a stringEven if they type 123, you get the text "123".→
- 3Prohibited operationsWhy you can't do maths on the text input() gives you.→
- 4Type castingConvert between types with int(), float() and str().→
- 5String operators+ joins strings and * repeats them.→
- 6QuizCheck what you've learned about input and conversions.→