Hello all
I have two questions
The first is why one change calculator works and the other doesn't.
The second question is about how to efficiently communicate and compare dictionary values while citing who they belong to.
Starting with the first you have two change calculator programs
Program A this functions
https://visualfractions.com/calculator/m...s-3-mod-5/
Where 3 mod 5 is 3 is over my head logic for now. I could probably watch a video and understand how it works so this isn't really my question but I think its related to my ignorance. What I'm really asking is why does the first program work and not the second and if there a simple way to fix the second program or am I chasing a waterfall trying to use that method?
The second question is a little simpler to ask.
I'm trying to count NPCs in a dictionary and compare their values while citing who they are. So far I have the count right but comparing the values and citing who they belong too has been a
.
These are total personality and ability scores next to names.
How would I print that C-Paul has the highest ability score with 88 or that Grex has the highest personality score with 22? I have found ways where I can identify the max of all values. I'm trying to compare specific values and identify the person who has it. I'm also wondering if I can name the values and reference the values by whatever variable or name so its ['Name','personality' ,'ability']?
I have two questions
The first is why one change calculator works and the other doesn't.
The second question is about how to efficiently communicate and compare dictionary values while citing who they belong to.
Starting with the first you have two change calculator programs
Program A this functions
currency=float(input("enter value in $- ")) currency=currency*100 dollar=int(currency/100) print("dollar-",dollar) ra=currency%100 #print(ra) quarters=int(ra/25) print("quarters-",quarters) ra=int(ra%25) #print(ra)) dimes=int(ra/10) print("dime-",dimes) ra=int(ra%10) #print(ra) nickel=int(ra/5) print("nickel-",nickel) ra=int(ra%5) #print(ra) penny=int(ra/1) print("penny-",penny)Program B this partially functions
dollar=1 quarter=.25 dime=.10 nickel=.05 penny=.01 total=float(input("Enter the total amount: ")) print("The total can be reduced to") print (int(total/dollar),"Dollars") #Amount of dollars total = total%dollar print (int(total/quarter),"Quarters") #Amount of quarters total = total%quarter print (int(total/dime),"Dimes") #Amount of dimes total = total%dime print (int(total/nickel),"Nickel") #Amount of nickel total = total%nickel print (int(total/penny),"Pennies") #Amount of penniesI'm looking for a simple solution to fix the second program. I think the flaw is related to how I was programming blind with the mod operator. Modding a smaller number against a larger one like in this example
https://visualfractions.com/calculator/m...s-3-mod-5/
Where 3 mod 5 is 3 is over my head logic for now. I could probably watch a video and understand how it works so this isn't really my question but I think its related to my ignorance. What I'm really asking is why does the first program work and not the second and if there a simple way to fix the second program or am I chasing a waterfall trying to use that method?
The second question is a little simpler to ask.
I'm trying to count NPCs in a dictionary and compare their values while citing who they are. So far I have the count right but comparing the values and citing who they belong too has been a


dictStudents={'001':['Grex','22','40'], '002':['C-Paul','02' ,'88'], '003':['Aquille','11','76']} dictionary_length = len(dictStudents) print('The school has:',dictionary_length,'students.') maximum = max(dictStudents[2], key=dictStudents[2].get) print(maximum, dictStudents[2][maximum])___
These are total personality and ability scores next to names.
How would I print that C-Paul has the highest ability score with 88 or that Grex has the highest personality score with 22? I have found ways where I can identify the max of all values. I'm trying to compare specific values and identify the person who has it. I'm also wondering if I can name the values and reference the values by whatever variable or name so its ['Name','personality' ,'ability']?
buran write Feb-25-2021, 07:17 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.