Chapter #6 – Flow of Control

Class 11 – Chapter 6 Solutions – PROGRAMMING EXERCISES #1
Write a program that takes the name and age of the user as input and displays a message whether the user is eligible to apply for a driving license or not. (the eligible age is 18 years).
Python Program
# Get user input for name and age
name = input("Enter your name: ")
age = int(input("Enter your age: ")) # Convert age to an integer
# Check eligibility for a driving license
if age >= 18:
print(f"{name}, you are eligible to apply for a driving license.")
else:
print(f"{name}, you are not eligible to apply for a driving license.")
You can checkout this code from Github here – Programming Exercise – 1
Explanation of the Code
Explanation of the Code
1. Input:
• The program prompts the user to enter their name using input().
• It then asks for their age, which is converted from a string to an integer using int().
2. Eligibility Check:
• An if statement checks if the user's age is 18 or older.
• If true, it prints a message confirming eligibility.
• If false, it prints a message indicating that they are not eligible.
Example Output:
Enter your name: Mohan
Enter your age: 19
Mohan, you are eligible to apply for a driving license.
NCERT Computer Science Class 11 – Chapter 6 Solutions – Q 6