Write a program that asks the user to input marks obtained in three tests. Your program should display the average test score.
Program
marks1 = int(input('Enter marks in test 1: '))
marks2 = int(input('Enter marks in test 2: '))
marks3 = int(input('Enter marks in test 3: '))
average = (marks1 + marks2 + marks3)/3
print('Average test score:',average)
Output
Enter marks in test 1: 78 Enter marks in test 2: 83 Enter marks in test 3: 67 Average test score: 76.0
Write a program that asks the user to input base and height of a triangle as integer. Your program should calculate and display the area of triangle using formula area = 1/2 * base * height.
Program
base = int(input('Enter base of triangle: '))
height = int(input('Enter height of triangle: '))
area = 1/2 * base * height
print('Area of triangle is',area)
Output
Enter base of triangle: 34 Enter height of triangle: 8 Area of triangle is 136.0
Write a program that asks the user to input his height in cetimeters. Your program should convert and display the height in Feet and inches. (Hint: 1 inch equals 2.54 centimeters and 1 foot equals 12 inches)
Program
cm = int(input('Enter your height in cm: '))
inches = cm / 2.54
ft = inches // 12
inches = inches % 12
print('Your height is',int(ft),'feet and',inches,'inches.')
Output
Enter your height in cm: 178 Your height is 5 feet and 10.078740157480311 inches.