Phase 1 - Level 2: Nested If & Multiple Conditions
Master nested conditions and multiple condition combinations.
10 programs · open one, then the next
Start with Check if Three Sides Form a Valid Triangle- 01Check if Three Sides Form a Valid TriangleIntermediateCheck whether three lengths can form a triangle using Python. Students trace all three strict inequalities and distinguish a flat shape from a valid triangle.Open example →py# Take three sides as input a = float(input("Enter side 1: ")) b = float(input("Enter side 2: ")) c = float(input("Enter side 3: "))
- 02Determine Triangle TypeIntermediateClassify a valid triangle as equilateral, isosceles, or scalene. A Python exercise for beginners on nested conditions, validation, and ordering equality tests.Open example →py# Take three sides as input a = float(input("Enter side 1: ")) b = float(input("Enter side 2: ")) c = float(input("Enter side 3: "))
- 03Grade CalculatorIntermediateTurn marks into letter grades with an ordered Python if-elif chain. Students examine cutoff scores, decimal marks, and why range validation is a separate step.Open example →py# Take marks as input marks = float(input("Enter marks (0-100): ")) # Assign grade based on marks
- 04Check if One Number is Multiple of OtherIntermediateCompare two integers for a multiple relationship in either direction. This Python lesson explains remainder tests, branch order, and the risk of zero divisors.Open example →py# Take two numbers as input num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))
- 05Time-based GreetingIntermediateChoose a greeting from a twenty-four-hour clock value. Beginners practice Python chained comparisons and trace which interval includes each boundary hour.Open example →py# Take hour as input hour = int(input("Enter hour (0-23): ")) # Determine greeting based on hour
- 06Check Voting EligibilityIntermediateUse a simple age threshold to practice if-else logic. Students trace integer input, an inclusive comparison, and the limits of this voting eligibility model.Open example →py# Take age as input age = int(input("Enter age: ")) # Check voting eligibility
- 07Check Even/Odd PairIntermediateClassify two integers as both even, both odd, or a mixed pair. A Python condition exercise on remainder tests, and, and using else for the remaining cases.Open example →py# Take two numbers num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))
- 08Check Alphabet RangeIntermediatePlace a letter in the a-to-m or n-to-z range using Python. Students explore nested checks, lowercasing, and the difference between Unicode letters and ASCII.Open example →py# Take character ch = input("Enter a character: ").lower() # Check range
- 09Print Day NameIntermediateMap a number from one through seven to a weekday name. A beginner Python walkthrough of equality tests, one selected branch, and an explicit invalid-input case.Open example →py# Take day number day = int(input("Enter day number (1-7): ")) # Print day name
- 10Days in MonthIntermediateFind a month's usual day count with Python membership tests. Beginners group month numbers, handle invalid choices, and see why February needs a year to vary.Open example →py# Take month number month = int(input("Enter month number (1-12): ")) # Determine days