Hi. My name is Devin. I am studying at the University of New Mexico. I am in a program sponsored by SONY Studios that teaches students how to create CGI effects for film or video games. One of the core classes that is part of the program is a newly added class called "intro to computer programming using Python". A lot of us are struggling because most of us (especially me) have never done any coding before. I am having a really rough time with this class and could use some help from someone on this board.

We have a homework assignment. let me post it so you all will know what it is:

Listing 3.4 of the textbook, ComputeChange.py, accepts a dollar and cents amount of money and outputs a multiset (a set that can contain more than one copy of an element) of coins consisting of pennies, nickels, dimes, quarters, and Sacagawea dollars with minimal cardinality.

Your mission is to modify this program as follows:

1) Your program must input two numbers: the total cost of a purchase and the amount of money paid. Both inputs are in British pounds with two decimal places.

2) Outputs the multiset of coins with minimal cardinality that is equal in value to the change due using the eight dominations pictured above. Note: in the modern British system, 1 pound equals 100 pence.

The first line your program’s output is exactly:

Your total change is: £□□□□.□□ (end)

Ok. so basically we are trying to make a program that asks for the cost of an item...then asks how much you paid...then computes the change you should receive, not in US Currency, but in British Currency. Here is the code I have written so far:

# Receive the amount

amount = float(input('Enter the cost of the item: £'))

total = float (input ('Enter the amount paid: £') )

change = int(paid * 100 - total * 100)

multiset = []

for nomination in [200, 100, 50, 20, 10, 5, 2, 1]:

count = change // nomination

change = change % nomination

for _ in range (count): multiset.append (nomination)

print (', '.join ('{:.2f}'.format (nomination / 100) for nomination in multiset) )

print ('Total change: £{:>4.2f}'.format (paid - total) )

# convert the amount to pence

remainingamount = int(amount * 100)

# find the number of two pounds

numberOfTwoPounds = remainingAmount // 200

remainingAmount = remainingAmount % 200

# find the number of one pound

numberOfOnePounds = remainingAmount // 100

remainingAmount = remainingAmount % 100

# find the number of fifty pence

numberOfFiftyPence = remainingAmount // 50

remainingAmount = remainingAmount % 50

# find the number of twenty pence

numberOfTwentyPence = remainingAmount // 20

remainingAmount = remainingAmount % 20

# find the number of ten pence

numberOfTenPence = remainingAmount // 10

remainingAmount = remainingAmount % 10

# find the number of five pence

numberOfFivePence = remainingAmount // 5

remainingAmount = remainingAmount % 5

# find the number of two pence in the remaining amount

numberOfTwoPence = remainingAmount // 2

remainingAmount = remainingAmount % 2

# find the number of pennies in the remaining amount

numberOfPennies = remainingAmount

Ok, so when I run this code I get a box asking me to enter the cost of the item. I put in the number 11.56 (the box asks me this question using a British pound symbol)

After I hit enter, a new box asks me to enter the amount paid in British pounds...I put 20.00.

At this point I get an error box that says "NameError: name 'paid' is not defined"...the red highlighted error is the following line of code:

change = int(paid * 100 - total * 100)

So. my question is what am I doing wrong and what do I need to change in order for this code to work properly. I want to make clear that I am not trying to get anyone to necessarily "do my homework for me" I just really need some guidance and help on what the problem is, and how to fix it. I am sorry this post is so long, I am just trying to explain this as thoroughly as I can. The assignment is due tonight by midnight. If someone could help me out, I would really appreciate it. Thank You

Tweet This+ 1 thisPost To Linkedin