Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  1. Atyourcomputer,launchPython.

  2. 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.

  3. Save the file on your Desktop as a file named: calculate.py

  4. AsthefirstlineofcodeinthenewfileinIDLE,typeacommentusingyourfirst

    and last name, like so:

    # Post Malone

  5. PressEnter.

Note: Other than this comment you just typed, do not type any other comments in the script.

1

THE INPUTS

  1. Below the comment and on a new line, declare a variable named billAmount

  2. 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.

  3. Onanewline,declareavariablenamedtipPercent.

  4. 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.

  5. Onanewline,declareavariablenamednumPersons

  6. 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:

  1. Declare a variable named tipAmount and assign as its value the product of the billAmount times the tipPercent variables.

  2. Declare a variable named totalBill and assign as its value the sum of the billAmount and the tipAmount variables.

  3. 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.

  1. Print the tip amount and include a message indicating this is the tip amount.

  2. 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.

  3. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Advance warning and an explanation for the layoff.

Answered: 1 week ago