Exercises A
question one.py
emotion = input("How are you feeling today? ")
### insert line of code here to say:
### I am feeling {emotion} too.
### Where {emotion} is the value of the variable above.
### For example, sample output might be:
### -------------------------------------
### How are you feeling today? sad
### I am feeling sad too.
### How are you feeling today? happy
### I am feeling happy too.
### How are you feeling today? excited
### I am feeling excited too.
question two.py
password = "fiddlesticks"
guess = input("What is the password?")
if password == guess:
### insert line of code here to say 'Correct password!'
question three.py
import random
age = random.randint(12,18)
print("My age is between 12 and 18.")
guess = int(input("Guess my age: "))
if guess == age:
### insert code here to say "Correct guess!"
else:
### insert code here to say my correct age.
### For example:
### "Incorrect guess, my age was actually 13."
### "Incorrect guess, my age was actually 18."
### "Incorrect guess, my age was actually 12."
question four.py
order_total = 0.0
still_water = 0.70 # 70c
sparkling_water = 1.95 # $1.95
print("Would you like a bottle of still water for 70c?")
still = input("enter Yes or No: ")
if still == "Yes":
order_total = order_total + still_water
### Ask the user if they would like a bottle of sparkling water.
### If they answer Yes, then
### add the cost of the sparkling water to the order total.
print("Your order comes to a total of: $" + str(order_total))
question five.py
print("Rectangle Perimeter and Area Calculator")
area = 0 # variable to store area of rectangle
perimeter = 0 # variable to store perimeter of rectangle
length = float(input("Enter length of rectangle (m): "))
width = float(input("Enter width of rectangle (m): "))
### insert code here to calculate value of area
### insert code here to calculate value of perimeter
print("The area of your rectangle is: " + str(area) + "m2")
print("The perimeter of your rectangle is: " + str(perimeter) + "m")