PythonProgramming_Week1
1. Write a program “Lab1B” that prompts for the input for and displays the following information: • Your name • The city where you were born • Your favorite sports team • Your undergraduate major 2. A car's miles per gallon (MPG) can be calculated with the following formula: MPG = Miles driven ÷ Gallons of gas used Write a program “Lab1B” that asks the user for the number of miles driven and the gallons of gas used. It should calculate the car's MPG and display the result. Note: To format floating point output with a dollar sign and commas, to two decimal places, use the String class's format() method like so: print('The MPG is ${:,.2f}'.format(mpg)). 3. Write a program “Lab1B” that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food and then calculate the amount of an 20% tip and 5% meal tax. Display each of these amounts and the total. Note: you may use functions round() and format() together for output. For example, to print tax value, you may use “print('Tax is $' + format(round(tax,2), ",.2f") )” statement.
Written for
- Institution
- Python Programming
- Course
- Python Programming
Document information
- Uploaded on
- July 22, 2023
- Number of pages
- 3
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
pythonprogrammingweek1
Also available in package deal