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 TriangleIntermediateTake three sides and check if they form 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 TypeIntermediateIf sides form a valid triangle, determine if it is equilateral, isosceles, or scalene.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 CalculatorIntermediateTake marks (0-100) and print the corresponding grade (A/B/C/D/F).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 OtherIntermediateCheck if one of two given numbers is a multiple of the other.Open example →py# Take two numbers as input num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))
- 05Time-based GreetingIntermediateTake the hour of the day (0-23) and print "Good Morning", "Good Afternoon", "Good Evening", or "Good Night".Open example →py# Take hour as input hour = int(input("Enter hour (0-23): ")) # Determine greeting based on hour
- 06Check Voting EligibilityIntermediateCheck voting eligibility for a given age (18+).Open example →py# Take age as input age = int(input("Enter age: ")) # Check voting eligibility
- 07Check Even/Odd PairIntermediateTake two numbers and determine whether both are even, both are odd, or one is even and one is odd.Open example →py# Take two numbers num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))
- 08Check Alphabet RangeIntermediateTake an alphabet character and check if it lies between 'a' and 'm' or 'n' and 'z'.Open example →py# Take character ch = input("Enter a character: ").lower() # Check range
- 09Print Day NameIntermediateTake a day number (1-7) and print the corresponding day name.Open example →py# Take day number day = int(input("Enter day number (1-7): ")) # Print day name
- 10Days in MonthIntermediateTake a month number (1-12) and print the number of days in that month (ignore leap years).Open example →py# Take month number month = int(input("Enter month number (1-12): ")) # Determine days