A.
Exercises demonstrating the use of formatted output
#A program to convert a value in kilograms to pounds
weight_in_kilograms = float(input('Enter weight in kilograms'))
weight_in_pounds = weight_in_kg * 2.2
print(f'The weight in pounds is: {weight_in_pounds: .2f}')
#A program to compute the body mass index of a person
#Get weight and height
weight = float(input('Enter weight: '))
height = float(input('Enter height: '))
#Compute bmi
bmi = weight / (height * height)
#Display bmi
print(f'The body mass index of the person is: {bmi: .2f}')
B. Exercises demonstrating the use of decision structures
#A program to output negative or positive
#based on the number that is input
#Get number
number = float(input('Enter number'))
#Check if number is greater than zero
if number > 0:
print('The number is positive')
else:
print('The number is negative')
#A program to print out the taller of two people
#Get heights of persons A and B
height_A = float(input('Enter height of person A: '))
height_B = float(input('Enter height of person B: '))
#Compare heights
if height_A > height_B:
print('Person A is taller than person B')
else:
print('Person B is taller than person A')
#A program to print out the older of two people
#Get age of persons A and B
age_A = int(input('Enter age of person A: '))
age_B = int(input('Enter age of person B: '))
#Compare ages
if age_A > age_B:
print('Person A is older than person B')
else:
print('Person B is older than person A')