Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Assignment 1 – Python

Answer Part 1

## Declare variables numberOfInches, feet and remaningInches
numberOfInches = 0
feet = 0
remaningInches = 0

##Accept the input from user 'numberOfInches'
numberOfInches =int(input("Enter number of inches: "))

##Calculate and convert 'inches' to 'feet and inches'
feet = numberOfInches // 12
remaningInches = numberOfInches % 12

##Display the output 'feet' and 'numberOfInches'
print(numberOfInches, "inches equals", feet, "feet and", remaningInches, "inches.")


Part 2

## Declare variables real food, tax, tip and total
food = 0.0
tax = 0.0
tip = 0.0
total = 0.0

## Constants for the tax rate .07 and tip rate .18
TAX_RATE = 0.07
TIP_RATE = 0.18

## Accept the input from user 'food'
food = float(input("Enter the charge for food: "))

## Calculate the tip
tip = food * TIP_RATE

## Calculate the tax
tax = food * TAX_RATE

## Calculate the total
total = food + tip + tax

## Display the tip, tax and total.
print ("Tip: $", format(tip, '.2f'))
print ("Tax: $", format(tax, '.2f'))
print ("Total: $", format(total, '.2f'))

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!