0% found this document useful (0 votes)
2 views7 pages

Final Python Program

The document contains a series of Python programs that perform various mathematical and logical operations, such as calculating sums, areas, and determining eligibility based on age. It includes functions for checking odd/even numbers, calculating percentages and grades, finding the largest of three numbers, generating natural numbers, and calculating factorials. Each program is designed to take user input and display the results accordingly.

Uploaded by

jasrajsujeetmaan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Final Python Program

The document contains a series of Python programs that perform various mathematical and logical operations, such as calculating sums, areas, and determining eligibility based on age. It includes functions for checking odd/even numbers, calculating percentages and grades, finding the largest of three numbers, generating natural numbers, and calculating factorials. Each program is designed to take user input and display the results accordingly.

Uploaded by

jasrajsujeetmaan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PROGRAMMES

1. Write a program in python to input two numbers. Calculate their sum, difference, product and
quotient.

a=int(input(“Enter your first number”))

b=int(input(“Enter your second number”))

print(“sum= ”,a+b)

print(“difference= ”,a-b)

print(“product= ”,a*b)
print(“quotient= ”,a/b)

2. Write a program in python to input radius of a circle. Calculate diameter, circumference and
area of circle.

r=int(input(“Enter radius of circle”))

print(“diameter= ”,2*r)

print(“circumference=”,2*r*3.14)

print(“area= ”,3.14*r*r)

3. Write a program in python to input length and breadth of a [Link] perimeter and area
of rectangle.

l=int(input(“Enter length of rect.”))

b=int(input(“Enter breadth of rect.”))

print(“area= “,l*b)

print(“perimeter= ”,2*(l+b))

4. Write a program in python to input marks of 6 [Link] total, average and percentage of
the marks. If percentage> 33 then print "pass" else print "fail".
a=int(input(“Enter your marks of English ”))

b=int(input(“Enter your marks of hindi”))

c=int(input(“Enter your marks of maths”))

d=int(input(“Enter your marks of science”))

e=int(input(“Enter your marks of sst”))

f=int(input(“Enter your marks of punjabi”))

total=a+b+c+d+e+f

percentage=total/600*100

average=total/6

print(“your total marks are”,total)

print(“your percentage is “,percentage)

print(“your average is “,average)

if percentage>33:

print(“Pass”)

else:

print(“Fail”)

5. Write a program in python to input age of a person. If age >=18 then print" you can vote" else
print "you can not vote".

age=int(input(“Enter your age”))

if age>=18:

print(“you can vote”)


else:

print(“you can not vote”)


6. Write a program in python to input two numbers and find greater number.

a=int(input(“Enter first no.”))

b=int(input(“Enter second no”))

if a>b:

print(“the greater number is “,a)

elif b>a:

print(“the greater number is”,b)

else:

print(“both are equal”)

7. Write a program in python to input age of a student. If age>10 then print "you are eligible for
scholarship" else print "you are not eligible for scholarship". Print “Thank You”.

age=int(input(“enter your age”))

if age>10:

print("you are eligible for scholarship")

else:

print("you are not eligible for scholarship")

print(“Thank You”)

8. Write a program in python to input a number and display whether a number is positive,
negative or zero.

n=int(input(“enter number”))

if n>0:

print(“the number is positive”)


elif n<0:
print(“the number is negative”)

else:

print(“ the number is 0”)

[Link] a program in python to input a number and display its square and cube.

a=int(input("Enter a number"))

square=a**2

Cube=a**3

print("square of a number",a,"is",square)

print("cube of a number",a,"is",cube)

10. Write a program in python to input purchase amount and display its discount (8%)and net
amount .

a=int(input("Enter purchase amount"))

disc=0.08*a

na=a-disc

print("Discount=", disc)

print("Net amount=", na)

11. Write a program in python to input a number and display whether it is even or odd

a=int(input("Enter a number"))

if a % 2 == 0:

print(a, "is an even number.")

else:
print(a, "is an odd number.")

12. Write a program in python to assign a day of the week (any value from 1 to 7) and display
the day of the week.

a=int(input(“Enter any number from 1 to 7”)

if a==1:

day=”SUNDAY”

elif a==2:

day =”MONDAY”

elif a==3:

day =”TUESDAY”

elif a==4:

day =”WEDNESDAY”

elif a==5:

day =”THURSDAY”

elif a==6:

day =”FRIDAY”

elif a==7:

day =”SATURDAY”

print(“The day of the week of number”,a,”is”,day,”.”)

13. Write a program in python to input a number and display whether it is divisible by 5 or not.

a= int(input(“Enter a number”))

if a%5==0:

print(a, “is divisible by 5”)


else:

print(a,”is not divisible by 5”)

14. write a program in python to display the even number between 1 to 10 using for loop.

for i in range (2,11,2):

print(i)

15. Write a program in python to input a number and display its table from 1 to 10.

a= int(input(“Enter a number”))

for i in range (1,11):

print(a,”X”,i,”=”,a*i)

IN THE LAB
1. def oddeven(num):
if num%2==0:
print(“this number is even”)
else:
print(“this number is odd”)
return
2. def calcpercentgrade(total):
percentage= total/5
if percentage>=90 and percentage<=100:
grade=’A’
elif percentage>=75 and percentage<90:
grade=’B’
elif percentage>=60 and percentage<75:
grade=’C’
else:
grade=’D’
print(“percentage= “,percentage)
print(“grade= “,grade)
return
3. def largest(a,b,c):
if a>b and a>c:
print(a,”is largest”)
elif b>a and b>c:
print(b,”is largest”)
else:
print(c,”is largest”)
return
4. def natural (a):

for i in range (1,a+1):

print(i)

return

5. def factorial (num):


fact=1
for i in range (i,num+1):
fact=fact*i
print(“ factorial= “,fact)
return

You might also like