4.1.1–4.1.2
Decisions with if and if-else (4.1.1–4.1.2) is a Class 10 Computer Science lesson for the Punjab boards. It walks through the idea in plain steps, then sets a short check, in English, Urdu or Roman Urdu.
Your guide: Miss HiraExplains computers with chai, cricket and your phone.
Chapter 1 of every subject is free. Unlock every chapter of this class with the full course.
Unlock full courseAlready paid? Sign in with the Google account you paid with.
Control structures manage decisions and repetition. Decision making lets a program choose what to do, like taking an umbrella only if it rains.
if runs its indented block only when the condition is True: if temperature > 30: print("It's a hot day"). The colon and the indentation are compulsory; wrong indentation gives an IndentationError.
if-else adds a second block that runs when the condition is False. With temperature = 15, the else block prints It's not a hot day.
Step 1 / 1
Control structures manage decisions and repetition. Decision making lets a program choose what to do, like taking an umbrella only if it rains.
if runs its indented block only when the condition is True: if temperature > 30: print("It's a hot day"). The colon and the indentation are compulsory; wrong indentation gives an IndentationError.
if-else adds a second block that runs when the condition is False. With temperature = 15, the else block prints It's not a hot day.
if = one path that may be skipped; if-else = exactly one of two paths always runs.
Found a mistake? Tell us the lesson and the line at exciting@boringeducation.com.
No ads. Tell us what to fix.