0% found this document useful (0 votes)
9 views

Python practicals questions

Uploaded by

Abhishek Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python practicals questions

Uploaded by

Abhishek Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Q.1 write a python program to accept three integers and print the largest of the three.

num1 = int(input(“enter the first number”))


num2 = int(input(“enter the Second number”))
num3 = int(input(“enter the Third number”))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)

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.

a=int(input('Enter the first integer:'))


b=int(input('Enter the second integer:'))
Sum=a+b
print('The two integers are:', a, b)
print('The sum of two integers are:', Sum)

Q.6 Write a program to accept the marks of five subjects and calculate the average marks.

a=float(input('Enter the marks of first subject:'))


b=float(input('Enter the marks of second subject:'))
c=float(input('Enter the marks of third subject:'))
d=float(input('Enter the marks of fourth subject:'))
e=float(input('Enter the marks of fifth subject:'))
Average=(a+b+c+d+e)/5
print('The average marks are:', Average)

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.

a=int(input('Enter the year:'))


if a%4==0:
print('This year is a leap year')
else:
print('This year is not a leap year')

Q.9 Write a program to input a number and check whether it is positive, negative or zero.

a=float(input('Enter the number:'))


if a>=0:
if a==0:
print('The number is zero')
else:
print('The number is a positive number')
else:
print('The number is a negative number')

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

a=float(input('Enter the percentage marks:'))


if a>=90:
print('The student has got an A grade')
elif a>=75 and a<90:
print('The student has got a B grade')
elif a>=60 and a<75:
print('The student has got a C grade')
else:
print('The student has got a D grade')
Q11. write a program to print table of a given number.

i=1
While(I<=10):
T=2*i
Print(t,end=” “)
i=i+1

Q12. program to display numbers from 1 to 5.


i=1
n=5
while i <= n:
print(i)
i=i+1

Q13. Write a program to print first 10 natural number.

For i in range (1,11):


Print (i)

Q.14.Write a program to print table of a number accepted from user


Num=int(input( “enter the number”)
For i in range(1,11):
Print(Num*i)

Q.15 find the Squre root 1 to 5


numbers = [1, 2, 3, 4, 5]
for i in numbers:
square = i ** 2
print("Square of:", i, "is:", square)

You might also like