This unit included this program for making change:

amount = int(input("How much does your item cost in cents?"))
amountOwed = 100 - amount
print(amountOwed//25, "quarters")
amountOwed = amountOwed % 25
print(amountOwed//10, "dimes")
amountOwed = amountOwed % 10
print(amountOwed//5, "nickels")
amountOwed = amountOwed % 5
print(amountOwed//1, "pennies")

Which of the following would correctly modify the program so that the user can input the amount paid.

Follow this link to try them out!

(2 points)
Responses

Remove 100 from line 2 and enter the following in its place: input("How much did you pay in cents?")
Remove 100 from line 2 and enter the following in its place: input("How much did you pay in cents?")

Add a line below line 1 and enter the following on it: amountPaid = input("How much did you pay in cents?") , then change the 100 in the amountOwed calculation to amountPaid.
Add a line below line 1 and enter the following on it: amountPaid = input("How much did you pay in cents?") , then change the 100 in the amountOwed calculation to amountPaid.

Add a line below line 1 and enter the following on it: amountPaid = int(input("How much did you pay in cents?")) , then change the 100 in the amountOwed calculation to amountPaid.
Add a line below line 1 and enter the following on it: amountPaid = int(input("How much did you pay in cents?")) , then change the 100 in the amountOwed calculation to amountPaid.

Add a line below line 1 and enter the following on it: amountPaid = 100, then change the 100 in the amountOwed calculation to amountPaid.
Add a line below line 1 and enter the following on it: amountPaid = 100, then change the 100 in the amountOwed calculation to amountPaid.
Question 2
In trinket.io, write the following code into a new trinket. (You can also use any IDE or remote environment that will allow display environments. PythonAnywhere will NOT work for this)

(If you do not have trinket.io setup, please check the lesson intro page for directions on setting up trinket.io)

import turtle
Mark = turtle.Turtle()
Mark.back(80)
Mark.left(90)
Mark.forward(50)
Mark.right(90)
Mark.forward(80)
Mark.back(80)
Mark.left(90)
Mark.forward(50)
Mark.right(90)
Mark.forward(80)

What shape will the turtle draw?

(2 points)
Responses

B
B

E
E

M
M

F
F
Question 3
What is the result of the following code in PythonAnywhere?

print(0.1 + 0.1 + 0.1)

(2 points)
Responses

0.001
0.001

0.3
0.3

0.3000000000000
0.3000000000000

0.30000000000000004
0.30000000000000004
Question 4
Why did the result happen in the previous question?(2 points)
Responses

Memory is limited in Python to 3GB
Memory is limited in Python to 3GB

Python is awesome at math!
Python is awesome at math!

It is not simple to store fractions and decimals in binary, and oftentimes even the simplest decimals end up with a repeating component in their binary representation.
It is not simple to store fractions and decimals in binary, and oftentimes even the simplest decimals end up with a repeating component in their binary representation.

Python is extremely dumb.
Python is extremely dumb.
Question 5
What will the output of the following code be if the user inputs 2.5 as the first number and 3.4 as the second?

x = float(input("Enter a number: "))
y = float(input("Enter another number: "))
z = (x + y) / 2
print(z)

(2 points)
Responses

It'll throw and "unsupported operand type" error.
It'll throw and "unsupported operand type" error.

2.9
2.9

2.95
2.95

3

1 answer

Here are the answers to the questions:

Question 1

The correct option to allow the user to input the amount paid and modify the program accordingly is: Add a line below line 1 and enter the following on it: amountPaid = int(input("How much did you pay in cents?")) , then change the 100 in the amountOwed calculation to amountPaid.

Question 2

The turtle drawing will create the shape: M
The movements of the turtle will form the outline of the letter "M".

Question 3

The result of the code print(0.1 + 0.1 + 0.1) will be: 0.30000000000000004
This outcome happens due to floating-point precision errors in binary representation.

Question 4

The reason for the result in the previous question is: It is not simple to store fractions and decimals in binary, and oftentimes even the simplest decimals end up with a repeating component in their binary representation.

Question 5

For the inputs of 2.5 and 3.4, the output of the code will be: 2.95
The calculation (x + y) / 2 will yield (2.5 + 3.4) / 2 = 5.9 / 2 = 2.95.

Let me know if you need any further assistance!

Similar Questions
    1. answers icon 0 answers
  1. I’m using VB 2008. I need towrite a simple program that calculates total sales of purchases. The program should accept item
    1. answers icon 0 answers
  2. I’m using VB 2008. I need towrite a simple program that calculates total sales of purchases. The program should accept item
    1. answers icon 1 answer
    1. answers icon 0 answers
more similar questions