Learn Python basics, functions, lists and dictionaries with explained code.
Weeks 1–2 Python basics
Concept & theory
Indentation defines blocks. Variables bind names to objects; input() returns a string; int() converts numeric text; lists are ordered mutable containers.
Example code
name = input("Name: ")
marks = int(input("Marks: "))
if marks >= 40:
print(f"{name}: pass")
else:
print(f"{name}: retry")
Code explained
input reads text; int converts marks; the if/else branch compares marks with 40; f-string inserts the name into output.
Try it yourself
Validate marks in 0–100 and print a grade for each score band.
Weeks 3–4 Functions, lists and dictionaries
Concept & theory
Functions use def and return. Lists index by position; dictionaries map keys to values. Use get() for a default when a key is absent.
Example code
def average(scores):
return sum(scores) / len(scores) if scores else 0
student = {"name": "Asha", "scores": [70, 80, 90]}
print(student["name"], average(student["scores"]))
Code explained
average guards against division by zero, then sums scores and divides by count. Dictionary keys access name and score list.
Try it yourself
Build a marks tracker for three subjects and print highest/lowest.