Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sort and count a bag of coins Specification: In python Language create a list of 30 integers. Use the following data to test your code.

Sort and count a bag of coins Specification: In python Language

image text in transcribed

create a list of 30 integers. Use the following data to test your code. bag_coin = [24,18,21,20,19,24,18,21,20,19,24,18,21,19,24,18,23,21,19,24,18,21,19,24,18,21,30,32,24,26]

Program Output: The bag contains the following coins:

Quarter: 7

Dime: 6

Nickel: 6

Penny: 5

Foreign: 6

Total value in the bag: $ 2.7

| I have a bag of coins. Design a program that can sort and count coins according to their size. The program should also contain the functions that display the tallies for each kind of coin and the total amount of money in the bag. There may be foreign coins mixed in with the normal coins. These coins should be tallied but not used to calculate the total cash, These are the diameters of US coins. QUARTER 24 mm DIME 18 mm NICKEL 21 mm PENNY 19 mm We will simulate the bag of coins using a list of 30 integers; The simplest solution is to use if..elif..else construct to tally the different coins from the bag. Return type Parameter list a tuple of each coin count None a bag of coins (using list to represent the bag) a tuple of each coin count Declare the size of each coin as global constant Create four functions to do the followings: I Function Name Description tally_coins Sort the coins by denomination display_coins Display each coin tally Display total value - call calculate_total) function inside it calculate_total Calculate and return total value of the bag main Create a bag using list of 30 integers Call tally_coins() and display_coins() functions float a bag of coins (using list to represent the bag) None

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago