A variable is a tiffin box. A list is your school bag. A function is the canteen uncle.
If Python still feels scary, read this once. Every idea here is something you already know from school.
Then teach it to a friend. That's how it sticks.
explained to kids (1/2)
Python, the simple way
Variable
A tiffin box with your name on it. Rice today, roti tomorrow. The name stays the same.
lunch = "rice"List
Books in your bag, in order. Python calls the first book number 0, not 1.
bag[0] # "maths"Dictionary
The class register. Say a roll number, get the name. Roll number is the key.
roll = {1: "Asha"}if/else
If it rains, games period is indoors. Else, everyone goes to the ground.
"indoor" if rain else "ground"for loop
Teacher calls every name in the register, one by one, till the last kid.
for kid in register:while loop
Keep running laps till the whistle blows. You don't know the number of laps before.
while not whistle:explained to kids (2/2)
Python, the simple way
Function
Canteen uncle. Give him 10 rupees, get a samosa. Same steps every single time.
def canteen(money):import
Why write your own book? Borrow one from the library and use it.
import pandas as pdString
Letter beads on a bracelet. Pick any bead by its place, starting at 0.
name[0] # "R"Boolean
Attendance has only two answers. Present or absent. True or False.
present = Truetry/except
Try flying the kite. If the string snaps, play cricket instead of crying.
try: ... except: ...DataFrame
The big marks chart on the class wall. Rows are kids, columns are subjects.
pd.read_csv("marks.csv")Ready for interview Python?
Once these click, try the 12 Python programs interviewers love to ask.