answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
faltersainse [42]
1 year ago
10

5.19 LAB: Exact change - functions

Computers and Technology
2 answers:
matrenka [14]1 year ago
6 0

Answer:

def exact_change(user_total):

    if user_total <=0:

         print("No change")

    else:

         num_dollars = int(user_total/100)

         user_total = user_total % 100

         num_quarters= int(user_total/25)

         user_total = user_total % 25

         num_dimes= int(user_total/10)

         user_total = user_total % 10

         num_nickels= int(user_total/5)

         num_pennies= user_total % 5

         if num_dollars >= 1:

              if num_dollars == 1:

                   print(str(num_dollars)+" num_dollars")

              else:

                   print(str(num_dollars)+" amountdollars")

         if num_quarters>= 1:

              if num_quarters== 1:

                   print(str(num_quarters)+" quarter")

              else:

                   print(str(num_quarters)+" quarters")

         if num_dimes>= 1:

              if num_dimes== 1:

                   print(str(num_dimes)+" dime")

              else:

                   print(str(num_dimes)+" dimes")

         if num_nickels>= 1:

              if num_nickels== 1:

                   print(str(num_nickels)+" nickel")

              else:

                   print(str(num_nickels)+" nickels")

         if num_pennies>= 1:

              if num_pennies== 1:

                   print(str(num_pennies)+" penny")

              else:

                   print(str(num_pennies)+" pennies")

           

user_total = int(input("Enter user_total Here:  "))

exact_change(user_total)

Explanation:

The explanation is long. So, I added it as an attachment.

Download txt
Reptile [31]1 year ago
6 0

Answer:

Written in Python:

def exact_change(user_total):

   num_dollars = user_total // 100 #convert to dollars

   user_total %= 100 #get remainder after conversion

   num_quarters = user_total // 25 #convert to quarters

   user_total %= 25 #get remainder after conversion

   num_dimes = user_total // 10 #convert to dimes

   user_total %= 10 #get remainder after conversion

   num_nickels = user_total // 5 #convert to nickels

   user_total %= 5 #get remainder after conversion

   num_pennies = user_total

   return(num_dollars, num_quarters, num_dimes, num_nickels, num_pennies)

if __name__ == '__main__':

   input_val = int(input()) #prompt user to input an integer

   num_dollars, num_quarters, num_dimes, num_nickels, num_pennies = exact_change(input_val) #recall exact_change function

   

   #define output statements to output number of exact_change variables:  

   #num_dollars, num_quarters, num_dimes, num_nickels, num_pennies  

   if input_val <=0: #if amount is zero

       print('no change') #print output

       

   else:

       if num_dollars > 1: #if number of dollars is greater than one

           print('%d dollars' % num_dollars) #print number of dollars

       elif num_dollars == 1: # if number of dollars equal 1

           print('%d dollar' % num_dollars) #print dollar in singular

       

       if num_quarters > 1: #if number of quarters is greater than one

           print('%d quarters' % num_quarters) #print number of quarters

       elif num_quarters ==1: # if number of quarters equal 1

           print('%d quarter' % num_quarters) #print quarter in singular

       

       if num_dimes > 1: #if number of dimes is greater than one

           print('%d dimes' % num_dimes) #print number of dimes

       elif num_dimes == 1: # if number of dimes equal 1

           print('%d dime' % num_dimes) #print dime in singular

           

       if num_nickels > 1: #if number of nickels is greater than one

           print('%d nickels' % num_nickels) #print number of nickels

       elif num_nickels == 1: # if number of nickels equal 1

           print('%d nickel' % num_nickels) #print nickel in singular

       

       if num_pennies >1: #if number pennies is greater than one

           print('%d pennies' % num_pennies) #print number of pennies

       elif num_pennies ==1: # if number of pennies equal 1

           print('%d penny' % num_pennies) #print penny in singular

Explanation:

It's really long, but it's necessary to get all the correct answers.

You might be interested in
Write the 8-bit signed-magnitude, two's complement, and ones' complement representations for each decimal number: +25, + 120, +
pshichka [43]

Answer:

Let's convert the decimals into signed 8-bit binary numbers.

As we need to find the 8-bit magnitude, so write the powers at each bit.

      <u>Sign -bit</u> <u>64</u> <u>32</u> <u>16</u> <u>8</u> <u>4</u> <u>2</u> <u>1</u>

+25 - 0 0 0 1 1 0 0 1

+120- 0 1 1 1 1 0 0 0

+82 - 0 1 0 1 0 0 1       0

-42 - 1 0 1 0 1 0 1 0

-111 - 1 1 1 0 1 1 1 1

One’s Complements:  

+25 (00011001) – 11100110

+120(01111000) - 10000111

+82(01010010) - 10101101

-42(10101010) - 01010101

-111(11101111)- 00010000

Two’s Complements:  

+25 (00011001) – 11100110+1 = 11100111

+120(01111000) – 10000111+1 = 10001000

+82(01010010) – 10101101+1= 10101110

-42(10101010) – 01010101+1= 01010110

-111(11101111)- 00010000+1= 00010001

Explanation:

To find the 8-bit signed magnitude follow this process:

For +120

  • put 0 at Sign-bit as there is plus sign before 120.
  • Put 1 at the largest power of 2 near to 120 and less than 120, so put 1 at 64.
  • Subtract 64 from 120, i.e. 120-64 = 56.
  • Then put 1 at 32, as it is the nearest power of 2 of 56. Then 56-32=24.
  • Then put 1 at 16 and 24-16 = 8.
  • Now put 1 at 8. 8-8 = 0, so put 0 at all rest places.

To find one’s complement of a number 00011001, find 11111111 – 00011001 or put 0 in place each 1 and 1 in place of each 0., i.e., 11100110.

Now to find Two’s complement of a number, just do binary addition of the number with 1.

6 0
1 year ago
An executive in a computer software firm works with his office door closed. At the same time every hour he opens the door to see
Masja [62]

Answer: (A) Fixed interval

Explanation:

 The fixed interval schedule is the type of schedule of the reinforcement in the operand conditioning in which the the initial response are rewarded by some specific amount of the time.

The main issue with the fixed interval schedule is that the people have to wait until the reinforcement schedule get occur and start their actual response of interval. This type of reinforcement schedule occur as the output value does not posses constant value all the time.

Therefore, Option (A) is correct.

4 0
2 years ago
Animated graphics that are displayed on the screen after a set of time when the computer is unattended.​
yan [13]

Answer:

Tab b. CTRL+A c. Alt d. Enter 18. Animated graphics that are displayed on the screen after a set of time when the computer is unattended. a. Screen Saver b. Title Bar c. Scroll Bar d.

Explanation:

Tab b. CTRL+A c. Alt d. Enter 16. Animated graphics that are displayed on the screen after a set of time when the computer is unattended

Computer-generated motion graphics[edit]. Before computers were widely available, motion graphics were costly and time-consuming, limiting their use to high-budget filmmaking and ...

7 0
1 year ago
Write a code segment to change the name of the Thing object something such that the new name consists of the old name with one c
ololo11 [35]

Answer:

import random

def name_change( name: list ) -> list :

   choice = random.choice( name )

   choice_index = name.index( choice )

   name.pop( choice_index )

   return name

Explanation:

The python source code above makes use of the random package to select an item from a list in the function "name_change" and the index of that item is gotten fro the list and popped from the list "name", then the name is returned.

To call the function, assign it to a variable and add a list ( must be a list ) as its argument then print the result.

6 0
1 year ago
We have said that the average number of comparisons need to find a target value in an n-element list using sequential search is
bija089 [108]

Answer:

Part a: If the list contains n elements (where n is odd) the middle term is at index (n-1)/2 and the number of comparisons are (n+1)/2.

Part b: If the list contains n elements (where n is even) the middle terms are  at index (n-2)/2 & n/2 and the number of comparisons are (n+2)/2.

Part c: The average number of comparisons for a list bearing n elements is 2n+3/4 comparisons.

Explanation:

Suppose the list is such that the starting index is 0.

Part a

If list has 15 elements, the middle item would be given at 7th index i.e.

there are 7 indices(0,1,2,3,4,5,6) below it and 7 indices(8,9,10,11,12,13,14) above it. It will have to run 8 comparisons  to find the middle term.

If list has 17 elements, the middle item would be given at 8th index i.e.

there are 8 indices(0,1,2,3,4,5,6,7) below it and 8 indices(9,10,11,12,13,14,15,16) above it.It will have to run 9 comparisons  to find the middle term.

If list has 21 elements, the middle item would be given at 10th index i.e.

there are 10 indices (0,1,2,3,4,5,6,7,8,9) below it and 10 indices (11,12,13,14,15,16,17,18,19,20) above it.It will have to run 11 comparisons  to find the middle term.

Now this indicates that if the list contains n elements (where n is odd) the middle term is at index (n-1)/2 and the number of comparisons are (n+1)/2.

Part b

If list has 16 elements, there are two middle terms as  one at would be at 7th index and the one at 8th index .There are 7 indices(0,1,2,3,4,5,6) below it and 7 indices(9,10,11,12,13,14,15) above it. It will have to run 9 comparisons  to find the middle terms.

If list has 18 elements, there are two middle terms as  one at would be at 8th index and the one at 9th index .There are 8 indices(0,1,2,3,4,5,6,7) below it and 8 indices(10,11,12,13,14,15,16,17) above it. It will have to run 10 comparisons  to find the middle terms.

If list has 20 elements, there are two middle terms as  one at would be at 9th index and the one at 10th index .There are 9 indices(0,1,2,3,4,5,6,7,8) below it and 9 indices(11,12,13,14,15,16,17,18,19) above it. It will have to run 11 comparisons  to find the middle terms.

Now this indicates that if the list contains n elements (where n is even) the middle terms are  at index (n-2)/2 & n/2 and the number of comparisons are (n+2)/2.

Part c

So the average number of comparisons is given as

((n+1)/2+(n+2)/2)/2=(2n+3)/4

So the average number of comparisons for a list bearing n elements is 2n+3/4 comparisons.

6 0
1 year ago
Other questions:
  • In three to four sentences, describe why CEOs (the chief executive officers, that is, the leaders of large companies) make very
    9·1 answer
  • A large department store has been attaching tags with barcodes to merchandise, and employees use barcode readers to scan merchan
    14·2 answers
  • Jeff wants to be an archeologist. He found the information below and wants to properly cite it for his own use. The information
    15·2 answers
  • 1. Do you consider Facebook, MySpace, and LinkedIn forms of disruptive or sustaining technology? Why?
    15·1 answer
  • What are two characteristics of a scalable network? (choose two.)?
    5·1 answer
  • Suppose your company has decided that it needs to make certain busy servers faster. Processes in the workload spend 60% of their
    5·1 answer
  • Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b
    11·2 answers
  • Compare the elements of the basic Software Development Life Cycle with 2 other models. How are they similar? How are they differ
    9·1 answer
  • int decode2(int x, int y, int z); is compiled into 32bit x86 assembly code. The body of the code is as follows: NOTE: x at %ebp+
    5·1 answer
  • A(n) ___________________ is a set of characters that the originator of the data uses to encrypt the text and the recipient of th
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!