Home › Python with Chai › Lesson 1
Chai is a Python program
Python with Chai, lesson 1 of 20. A short Hinglish video, simple English notes and code you can run, free.
Open the interactive lesson with Run button
The idea
A chai recipe and a Python program work the same way.
The ingredients (water, milk, tea leaves, sugar) are variables: a name with a value stored in it.
The recipe is a function: write the steps once, run them whenever you want.
"Keep heating until it boils" is a while loop: the work repeats as long as the condition is true.
The code
paani = "1 cup"
cheeni = 1
temp = 20
while temp < 100:
temp = temp + 20 # keep heating
print("Chai ready!")
Output:
Chai ready!
Try it yourself
- Create 4 variables for the ingredients of your favourite chai.
- Change
temp + 20totemp + 40. How many times does the loop run now?
Remember
If you can make chai, you can learn Python.
All lessons: Python with Chai