Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives To be able to write a user defined function with a parameter and a return value To get experience calling a function with an

image text in transcribedimage text in transcribedimage text in transcribed

Objectives To be able to write a user defined function with a parameter and a return value To get experience calling a function with an argument that is dependent on user input To get experience using the return value of the function Description A clothing store is running a sale and needs a program that will calculate the total purchase price of a transaction given the number of shirts, pairs of pants, and hats purchased in the transaction. The regular prices of these items is as follows: Shirt: $10.00 Pants: $20.00 Hats: $5.00 For this sale, shirts are 20% off, and hats are buy-one-get-one free. Pants are still full price. Write three functions that compute and return the total cost of a given number of a specific clothing items, given the current sale. The three functions must be named as follows: cost_shirts(num_shirts) cost_pants (num_pants) cost_hats(num_hats) For example, the function call cost_shirts (5) must return the final cost of 5 shirts, taking into account the shirt price and the sale. Your main code must ask the user for three inputs using the following prompts. Note that there is a space at the end of each prompt. Enter the number of shirts: Enter the number of pants: Enter the number of hats: After obtaining the inputs, call your functions appropriately, and use the return values to compute the total price of the purchase. Output the purchase price in this pattern: The final price of x shirts, x pants, and x hats is $x. Where the X's are the number of shirts, number of pants, number of hats, and total purchase price. Note: the total purchase price must be output with exactly two decimal places. Example run of the program: Enter the number of shirts: 1 Enter the number of pants: 1 Enter the number of hats: 3 The final price of 1 shirts, 1 pants, and 3 hats is $38.00. main.py 1 # Define your functions here 1 - N 3 if __name__ == '__main__': 4 # Type your code here. Your code must call your functions from here. 5 # Notice the indentation level

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions