Python practicals questions
Python practicals questions
Q.2 Write a python program that input a number and checks whether the given number is
odd or even.
num = int(input("Enter a number: "))
if (num % 2) == 0:
print(" Even")
else:
print("Odd")
Q.3 Write a python program that input a number and checks whether the given number is
divisible by another number or not.
num = int (input (“Enter the number whose divisibility needs to be checked:”))
div = int (input (“Enter the number with which divisibility needs to be checked:”))
if num%div == 0:
print (“The number is divisible.”)
else:
print (“The number is not divisible.”)
Q.4 write a python program that input two numbers and an arithmetic operator and
display the calculated result.
a=int(input(“enter the first number”))
b=int(input(“enter the Second number”))
c=int(input(“enter the operator ”))
If c==’/’:
R=a/b
elif c==’*’:
R=a*b
Elif c==’+’:
R=a+b
Elif c==’-’:
R=a-b
else:
Print(“invalid”)
Print(a,b,c,’=’,R)
Q.5 Write a program to accepts two integers and print their sum.
Q.6 Write a program to accept the marks of five subjects and calculate the average marks.
Q.7 Write a program that accepts the age and print if one is eligible to vote or not.
a=int(input('Enter your age:'))
if a>=18:
print('You are eligible to vote')
else:
print('You are not eligible to vote')
Q.8 Write a program to accept the year and check if it is a leap year or not.
Q.9 Write a program to input a number and check whether it is positive, negative or zero.
Q.10Write a program to input percentage marks of a student and find the grade as per
following criterion:
Marks Grade
>=90 A
75-90 B
60-75 C
Below 60 D
i=1
While(I<=10):
T=2*i
Print(t,end=” “)
i=i+1