0% found this document useful (0 votes)
33 views3 pages

Tomorrow Lab Programs

The document contains 7 Python programs: 1) A program to determine the eldest and youngest of 3 people by inputting their ages. 2) A program to generate the multiplication table of a number input by the user. 3) A program to calculate the sum of natural numbers up to a number input by the user. 4) A program to count and display the vowels and consonants in a name input by the user. 5) A program to calculate the average marks of a student across subjects, input the total number of subjects and marks for each, and print the grade based on percentage. 6) A program to generate and print all prime numbers up to a number input by the user.
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)
33 views3 pages

Tomorrow Lab Programs

The document contains 7 Python programs: 1) A program to determine the eldest and youngest of 3 people by inputting their ages. 2) A program to generate the multiplication table of a number input by the user. 3) A program to calculate the sum of natural numbers up to a number input by the user. 4) A program to count and display the vowels and consonants in a name input by the user. 5) A program to calculate the average marks of a student across subjects, input the total number of subjects and marks for each, and print the grade based on percentage. 6) A program to generate and print all prime numbers up to a number input by the user.
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
You are on page 1/ 3

1) If the age of Ram, Sam, and Khan are input through the keyboard, write a python program to

determine the eldest and youngest of the three.

ram=int(input("Enter the Ram age:"))


sam=int(input("Enter the Sam age:"))
khan=int(input("Enter the Khan age:"))

if (ram < sam and ram < khan):


print("Ram is Younger")
elif (sam < ram and sam < khan):
print ("Sam is Younger")
else:
print ("Khan is Younger")

2) Implement the python program to generate the multiplication table.

n=int(input("Enter any value:"))


print ("The Multiplication Table of: ",n)
for i in range(1,11):
print(n,'X',i,'=',n*I, end=”\n”)

3) Implement Python program to find sum of natural numbers


n=int(input("Enter any value:"))
sum=0
for i in range(1,n+1):
sum=sum+i
print(sum)

4) If the first name of a student is input through the keyboard, write a program to display the
vowels and consonants present in his/her name.
Program:
c=0
v=0
name=input("Enter your name:")
for ch in name:
if ch=='a' or ch=='A':
print(ch)
v=v+1
elif ch=='e' or ch=='E':
print(ch)
v=v+1
elif ch=='i' or ch=='I':
print(ch)
v=v+1
elif ch=='o' or ch=='O':
print(ch)
v=v+1
elif ch=='u' or ch=='U':
print(ch)
v=v+1
else:
c=c+1

print("Total no. of Vowels=",v)


print("Total no. of consonants=",c)

5) The marks obtained by a student in 5 different subjects are input through the keyboard. Find
the average and print the student grade as per the MITS examination policy as shown below.
% OBTAINED GRADE
90 - 100 O (Outstanding)
80 - 89 A+ (Excellent)
70 - 79 A (Very Good)
60 - 69 B+ (Good)
50 - 59 B (Above)
45 - 49 C (Average)
40 - 44 P (Pass)
< 40 F (Fail)

Program:
n=int(input("Enter the No. of Subjects:"))
total=0
avg=0

for i in range(1,n+1):
marks=int(input("Enter your subject Marks="))
total=total+marks

print(total)
avg=float(total/n)
print(round(avg,2))

if(avg>=90):
print("O (Outstanding)")
elif(avg>=80 and avg<90):
print("A+ (Excellent)")
elif(avg>=70 and avg<80):
print("A (Very Good)")
elif(avg>=60 and avg<70):
print("B+ (Good)")
elif(avg>=50 and avg<60):
print("B (Above)")
elif(avg>=45 and avg<50):
print("C (Average)")
elif(avg>=40 and avg<45):
print("C (Average)")
else:
print("Fail")

6) Implement Python Script to generate prime numbers series up to N.


n = int(input("Find prime numbers upto : "))
print("All prime numbers upto", n, "are : ")

for num in range(2, n + 1):


i=2

for i in range(2, num):


if (num % i == 0):
i = num
break

# If the number is prime then print it.


if (i != num):
print(num, end=" ")

7) Write a program to find all Armstrong number in the range of 0 and 999.
for num in range(0, 1000):
order = len(str(num))
sum = 0
n = num
while n > 0:
r = n % 10
sum = sum + r ** order
n = n // 10

if ((num == sum) and sum > 100):


print(num)

You might also like