269
hapter 8: DATA HANDLING
ype C: Programming Practice/Knowledge based Questions
1. Write a program to obtain principal amount, rate of interest and time from user and compute simple
interest.
2. Write a program to obtain temperatures of 7 days (Monday, Tuesday Sunday) and then display
average temperature of the week.
3. Write a program to obtain x, y, z from user and calculate expression : 4x4 +3yº +92 +67.
4. Write a program that reads a number of seconds and prints it in form : mins and seconds, e.g.,
200 seconds are printed as 3 mins and 20 seconds.
[Hint. use // and % to get minutes and seconds)
5. Write a program to take year as input and check if it is a leap year or not.
6. Write a program to take two numbers and print if the first number is fully divisible by second number
or not.
Answers
The following codes have been written using Python.
1.
pa = float(input("Enter the principal amount: "))
ri = int(input("Enter the rate of interest: "))
t = int(input("Enter the time period: "))
si = (p*ri*t)/100
print(si, "is your Simple Interest.")
2.
day_1 = float(input("Enter the temperature of Sunday: "))
day_2 = float(input("Enter the temperature of Monday: "))
day_3 = float(input("Enter the temperature of Tuesday: "))
day_4 = float(input("Enter the temperature of Wednesday: "))
day_5 = float(input("Enter the temperature of Thursday: "))
day_6 = float(input("Enter the temperature of Friday: "))
day_7 = float(input("Enter the temperature of Saturday: "))
avgtemp = (day_1 + day_2 + day_3 + day_4 + day_5 + day_6 + day_7)/7
print(avgtemp, "is the average temperature of the week.")
3.
x = int(input("Enter a number: "))
y = int(input("Enter a second number: "))
z = int(input("Enter a third number: "))
exp = 4*(x**4) + 3*(y**3) + 9*z + 6*3.14
print(exp)
4.
sec = int(input("Enter a number of seconds: "))
m = sec//60
rs = sec%60
print(sec, "is equivalent to", m, "minutes and", rs, "seconds.")
5.
y = int(input("Enter a year: "))
if y%4 == 0:
print(y, "is a leap year.")
else:
print(y, "is not a leap year.")
6.
x = int(input("Enter a number: "))
y = int(input("Enter a second number: "))
if x%y == 0:
print(x, "is fully divisible by", y)
else:
print(x, "is NOT fully divisible by", y)