Question
STARTING PYTHON AND CREATING A NEW FILE IN IDLE Atyourcomputer,launchPython. On the menu bar, click File >> New File (or press Ctrl + N) to
STARTING PYTHON AND CREATING A NEW FILE IN IDLE
-
Atyourcomputer,launchPython.
-
On the menu bar, click File >> New File (or press Ctrl + N) to create a new
blank file in IDLE. Do NOT type code or save your file using the command line shell. You will receive a 0 if you do. Use only IDLE to create and save your script.
-
Save the file on your Desktop as a file named: calculate.py
-
AsthefirstlineofcodeinthenewfileinIDLE,typeacommentusingyourfirst
and last name, like so:
# Post Malone
-
PressEnter.
Note: Other than this comment you just typed, do not type any other comments in the script.
1
THE INPUTS
-
Below the comment and on a new line, declare a variable named billAmount
-
Assign as the value for the billAmount variable, an input statement that asks
the user to enter the bill amount (a floating point number). Make sure your prompting text is clear and error free. Leave at least one space after the prompting text.
-
Onanewline,declareavariablenamedtipPercent.
-
Assign as the value for the tipPercent variable an input statement that asks the
user to enter the tip amount (a floating point number). Again, make sure your prompting text is clear and error free. Leave at least one space after the prompting text.
-
Onanewline,declareavariablenamednumPersons
-
Assign as the value for the numPersons variable an input statement that asks
the user to enter the number of persons who were at the dinner as an integer number). Once again, make sure your prompting text is clear and error free. Leave at least one space after the prompting text.
THE CALCULATIONS
On three separate lines:
-
Declare a variable named tipAmount and assign as its value the product of the billAmount times the tipPercent variables.
-
Declare a variable named totalBill and assign as its value the sum of the billAmount and the tipAmount variables.
-
Declare a variable named personPays and assign as its value the division of the totalBill variable by the numPersons variable.
2
THE OUTPUTS
For each of these outputs, use f-strings in the print statements. You will receive no credit for this assignment if you do not use f-strings.
-
Print the tip amount and include a message indicating this is the tip amount.
-
Print the total bill amount (format the amount to two decimal places and
have a comma separator for the output). Include a message that this is the
total bill amount.
-
Print the amount each person has to pay for dinner (format the amount to
two decimal places) and include a message that this is the amount each person has to pay.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started