Page 342 - Computer Science V2.0 Class 11
P. 342
iii. Output:
I
N
D
I
A
iv. Output:
12
v. Output:
2
3
4
4
6
8
6
9
vi. Output:
Current variable value: 7
Current variable value: 5
Good bye!
Current variable value: 4
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).
Ans. name = input("Enter your name: ")
age = int(input("Enter your age: "))
# Check eligibility for a driving license
if age >= 18:
print(f"Hello {name}! You are eligible to apply for a driving license.")
else:
print(f"Hello {name}! Sorry, you are not eligible to apply for a driving license yet.")
2. Write a function to print the table of a given number. The number has to be entered by the user.
Ans. def multTable (n) :
print('Multiplication Table of ', n, ':')
for i in range (1, 11):
print (n, '*', i, '=', n*i)
3. Write a program that prints minimum and maximum of five numbers entered by the user.
Ans. smallest = 0
largest = 0
for i in range(0,5):
num = int(input("Enter the number: "))
if i == 0:
smallest = largest = num
if(num < smallest):
smallest = num
if(num > largest):
largest = num
328 Touchpad Computer Science (Ver. 2.0)-XI

