Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with the following python coding questions: 1: Total Price Create a function called GetTotal that will take in to it the price per

Need help with the following python coding questions:

1:

image text in transcribedimage text in transcribedimage text in transcribed
Total Price Create a function called GetTotal that will take in to it the price per pound of an item and how much an item weighs. This weight is in pounds and ounces. Make sure when you write your function that your define your parameters in the right order (price, pounds, ounces). Your function needs to return the total cost of the item. You will need the following formula: Total Price = Price per pound * (Pounds + ounces/16) Because this problem needs to return a value representing currency or money, we need to round the total price to 2 decimal places. To do this will need to use the round function. In Python the syntax would be: your_variable = round(your_variable, # of spaces) your_variable = 323.47956 your_variable = round(your_variable, 2) print(your_variable) This would print: 323.48 For this problem you DO NOT have to write the code to call your function. Codio will run your function and send in various values in order to test your function. It is advideable to add the code calling your function and then clicking on the 'Try It!' button and 'Code Visualizer' link prior to clicking on the Check It! button. Here is the code you can use to run your function. mytotal = GetTotal(3.5, 5, 6) print(mytotal) Then click on the Try It! button. TRY IT Given the above test data (3.5, 5, and 6) the print statement should show you: 18.81 If your program is not running, click on the Code Visualizer link to run your code line by line. If that still doesn't help, copy the code to either IDLE or VS Code in order to better debug this program. Code Visualizer Before you click on the Check It! button make sure you remove your code that calls your function.Rectangle Volume Create a function called GetVolume that will take in to the length, width and height of a rectangular or prism type shape. Your function needs to return the volume of that shape. Make sure when you write yourfunction that you put your parameters in the right order (length, width and height). Given the length = 4, width = 6 and height = 3, the total volume of your shape is 72. Codio will run your function and send in various values in order to test your function. Prior to clicking on the Check It! button, add code to your solution to call yourfunction. Then click on the Try It! button. TRY IT If your program is not running, click on the Code Visualizer link to run your code line by line. If that still doesn't help, copy the code to either IDLE or VS Code in order to better debug this program. Code Visualizer Before you click on the Check It! button make sure you remove your code that calls your function. Correct Change Create a function in Python called GetChange that will accept the number of pennies, nickels, dimes and quarters. The function will then add up those values and check to see if the user has enough coins to make a whole dollar. If the user enters the right combination to make a dollar, have yourfunction return the message CONGRATULATIONS. Otherwise return TRY AGAIN. Make sure your message is all in upper case. For instance if the user enters the following: - pennies : 20 0 nickels = 5 - dimes = 2 0 quarters = 1 Since this totals 90 cents, the message TRY AGAIN would be returned. Codio will run your function and send in various values in order to test your function. Prior to clicking on the Check It! button, add code to your solution to call your function. Then click on the Try It! button. TRY IT If your program is not running, click on the Code Visualizer link to run your code line by line. If that still doesn't help. copy the code to either IDLE or VS Code in order to better debug this program. Code Visualizer Before you click on the Check It! button make sure you remove your code that calls your function

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions