The document contains code for 5 different Python programs:
1) To find the average of 5 subject marks and grade the average
2) To check if a number is even or odd
3) To find the largest of 3 numbers
4) To calculate simple interest given principal, rate, and time
5) To check if a character is a vowel or not
The document contains code for 5 different Python programs:
1) To find the average of 5 subject marks and grade the average
2) To check if a number is even or odd
3) To find the largest of 3 numbers
4) To calculate simple interest given principal, rate, and time
5) To check if a character is a vowel or not
The document contains code for 5 different Python programs:
1) To find the average of 5 subject marks and grade the average
2) To check if a number is even or odd
3) To find the largest of 3 numbers
4) To calculate simple interest given principal, rate, and time
5) To check if a character is a vowel or not
Objective: To find the average marks of a given set of marks.
Code: sub1=float(input("enter marks of first subject")) sub2=float(input("enter marks of second subject")) sub3=float(input("enter marks of third subject")) sub4=float(input("enter marks of fourth subject")) sub5=float(input("enter marks of fifth subject")) average=sub1/5+sub2/5+sub3/5+sub4/5+sub5/5 print("average marks=",average) if 100<=average<=90: print("your grade is A") elif 90<average<=80: print("your grade is B") elif 80<average<=70: print("your grade is C") elif 70<average<=60: print("your grade is D") elif 60<average<=50: print("your grade is E") elif 50<average<=0: print("your grade is f") Program 2 Objective: To check if the input number is even or odd. Code: # A number is even if division by 2 give a remainder of 0. # If remainder is 1, it is odd number. num = int(input("Enter a number: ")) if num %2 == 0: print("num is even") else: print("num is odd") Program 3: Objective: To find the largest number among a set of numbers. Code: num1=int(input("num1= ")) num2=int(input("num2= ")) num3=int(input("num3= ")) if (num1 >= num2) and (num1 >= num3): largest = num1 elif (num2 >= num1) and (num2 >= num3): largest = num2 else: largest = num3 print("The largest number between",num1,",",num2,"and",num3,"is",largest) Program 4: Objective: To find Simple Interest with the given data. Code: #To find simple interest p=float(input("enter p: ")) r=float(input("enter r: ")) t=float(input("enter t: ")) simpleinterest=(p*r*t)/100 print("simpleinterest is ",simpleinterest) Program 5: Objective: To check if the entered alphabet is vowel or not. Code: ch = input("Enter any character: "); if(ch=='a' or ch=='A' or ch=='e' or ch=='E' or ch=='i' or ch=='I' or ch=='o' or ch=='O' or ch=='u' or ch=='U'): print(ch, "is a vowel."); else: print(ch, "is not a vowel.");