Sitemap
Raksheshashank

Raksheshashank

Python Programming Exercise

1 min readNov 29, 2021
  1. Write a program that takes the name and age of the user as input an 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:’))
if age<18:
print(name,”is not eligible for driving license”)
else:
print(name,”is eligible for driving license”)

2. Write a function to print the table of a given number. The number has to be entered by the user.

Get Raksheshashank’s stories in your inbox

Join Medium for free to get updates from this writer.

Ans: def table(x):
for i in range(10):
print(x*(i+1))

3. Write a program that prints minimum and maximum of five numbers entered by the user.

Ans: a=int(input(“Enter the value a:”))
b=int(input(“Enter the value b:”))
c=int(input(“Enter the value c:”))
d=int(input(“Enter the value d:”))
e=int(input(“Enter the value e:”))
print(“min value is:”,min(a,b,c,d,e))
print(“max value is:”,max(a,b,c,d,e))

4. Write a program to check if the year entered by the user is a leap year or not

Ans: year=int(input(“Enter the year:”))
if year%4==0:
print(year,”is leap year”)
else:
print(year,”is not leap year”)

--

--