Python Program New Assignement
Python Program New Assignement
Q NO : 01
Body Mass Index Write a program that calculates and displays a
person’s body mass index (BMI). The BMI is often used to determine
whether a person is overweight or underweight for his or her height. A person’s
BMI is calculated with the following
where weight is measured in pounds and height is measured in inches. The program should
ask the user to enter his or her weight and height, then
display the user’s BMI. The pro- gram should also display a message
indicating whether the person has optimal weight, is underweight, or is overweight. A
person’s weight is considered to be optimal if his or her BMI is between 18.5
and 25. If the BMI is less than 18.5, the person is
considered to be underweight. If the BMI value is greater
than 25, the person is considered to be overweight.
Input
# 14. Body Mass Index
# formula:
# if his or her BMI is between 18.5 and 25. If the BMI is less
# be overweight.
message += "underweight"
message += "overweight"
print(‘message4’)
output
Q NO :02
Write a program that asks the user to enter a number of seconds and works as follows: •
There are 60 seconds in a minute. If the number of
seconds entered by the user is greater than or equal to 60,
the program should convert the number of seconds to minutes and seconds. • There are 3,600
seconds in an hour. If the number of seconds entered by the user is greater than or equal to
3,600, the program should convert the number of seconds to hours, minutes, and seconds. •
There are 86,400 seconds in a day. If the number of seconds entered by the user is
greater than or equal to 86,400, the program should convert the number of seconds to days,
hours, minutes, and seconds.
Input
# Write a program that asks the user to enter a number of
message = ""
if number_of_seconds < 0:
else:
print(message)
Output
Q NO :03
A software company sells a package that retails for $99. Quantity discounts are given
according to the following table:
Quantity Discount
10–19 10%
20–49 20%
50–99 30%
Write a program that asks the user to enter the number of packages purchased. The pro- gram
should then display the amount of the discount (if any) and the total amount of the purchase
after the discount.
Input
4040# 12. Software Sales
# table:
# Quantity Discount
# 10–19 10%
# 20–49 20%
# 50–99 30%
PRICE_PER_PACKAGE = 99.00
number_of_packages = float(input('\nEnter # of packages purchased: '))
display_message = ""
if number_of_packages < 0:
display_message = "Error. # of packages must be greater than 0.\nRe-run program and try
again."
else:
discount_percentage = 0
discount_percentage = 0
discount_percentage = .30
Output
Q NO : 04
The Fast Freight Shipping Company charges the following rates:
Write a program that asks the user to enter the weight of a package then displays the ship-
ping charges.
Input
weight_of_package = float(input("Enter weight of package: "))
shipping_charges = 0.0
if weight_of_package <= 2:
print(message)
Output
Q NO : 05
Serendipity Booksellers has a book club that awards points to its customers based on the
number of books purchased each month. The points are awarded as follows:
Write a program that asks the user to enter the number of books that he or she has pur-
chased this month, then displays the number of points awarded.
Input
number_of_books = int(input("Enter the number of books: "))
message = ""
if number_of_books < 0:
else:
message += "points."
print(message)
Output