๐ฏ By the end of this lesson you canโฆ
- Read input with input()
- Convert input to numbers
- Build a small interactive calculator
๐ Python
greet.py
๐ Tap a line to explain it
1name = input("What's your name? ")2age = int(input("How old are you? "))3print("Hi", name + "!")4print("Next year you'll be", age + 1)
๐ Python
bill-split.py
1bill = float(input())2people = int(input())3share = bill / people4print("Each person pays", round(share, 2))
๐ก Concept check
What is
type(input()) when the user types 42?๐ ๏ธ Bill splitter with tip
Read the bill amount and the number of people. Add a 10% tip, then print each personโs share rounded to 2 decimals.
๐ Key takeaways
input()always returns a string.int(input())orfloat(input())for numbers.- In lessons, input() reads the next line of the Inputs box.
Finished reading & practising?
Saved in this browser. Create a free account to keep it forever.