Python Exercise - Control Flow with if, elif, and else

Introduction

This unit focuses on Python’s control flow structures, particularly using if, elif, and else. You’ll create small programs to practice decision-making and flow control based on user input.

Task 1: Age Verification

Description:

Write a program that checks if the user’s age qualifies as being an adult.

Instructions:

  1. Prompt the user to enter their age.
  2. Use an if statement to check if the age is 18 or older.
  3. If true, print “You are an adult.”

Task 2: Even or Odd Number

Description:

Write a program that determines if a given number is even or odd.

Instructions:

  1. Prompt the user to enter a number.
  2. Use if and else to check if the number is divisible by 2.
  3. Print “The number is even” for even, and “The number is odd” for odd.

Task 3: Grade Evaluation

Description:

Create a program that evaluates a student’s grade and assigns a classification based on a scoring scale.

Instructions:

  1. Prompt the user to enter a grade between 0 and 100.
  2. Use if, elif, and else to categorize the grade as follows:
    • 90 and above: “Excellent”
    • 80 to 89: “Good”
    • 70 to 79: “Satisfactory”
    • 60 to 69: “Pass”
    • 50 to 59: “Poor”
    • Below 50: “Fail”

Task 4: Temperature Classification

Description:

Write a program that classifies the temperature in Celsius.

Instructions:

  1. Prompt the user to enter a temperature in Celsius.
  2. Use if, elif, and else to classify the temperature as:
    • 30°C or higher: “Hot”
    • 20°C to 29°C: “Warm”
    • 10°C to 19°C: “Cool”
    • Below 10°C: “Cold”

Updated: