Page 381 - Computer Science Class 11 Without Functions
P. 381
Program 19
Write a program to accept the values of principal, rate, and time and calculate the simple interest.
Ans. '''
Objective: To calculate the simple interest
Input: principal, rate, time
Output: simple interest
'''
principal = float(input("Enter the principal amount (P): "))
rate = float(input("Enter the rate of interest (R) as a percentage: "))
time = float(input("Enter the time period (T) in years: "))
rate /= 100
simpleInterest = principal * rate * time
print(f"Simple Interest: {simpleInterest:.2f}")
Program 20
Write a program that accepts the length in inches and prints the length in feet.
Ans. '''
Objective: To convert the length in inches to feet
Input: length in inches
Output: length in feet
'''
inches = float(input("Enter length in inches: "))
feet = inches / 12.0
print(f"Length in feet is: {feet} feet")
Program 21
Write a program that reads the colour of traffic light as user input in the form of a string and displays the output as
per the table given below:
Colour Output
Red STOP
Yellow Get ready
Green GO
Any other colour You have not entered the correct colour
Ans. '''
Objective: To display output according to traffic light color
Input: color
Output: output according to color
'''
color = input("Enter the color of the traffic light: ")
Practical 379

