Atm Bill Dispenser

Today, I was given an assignment to write a program to implement an atm dispenser in the following notes: 100, 50, 20, 10, and 5. If the amount is not a multiply of 5, the atm will return a list of 0. In the code are short explanations of why I used it. # asks the customer to enter an amount of number. atm = int(input("Enter an amount in a multiple of 5: ")) # This takes in a amount parameter which is the input from the user and return an array of bills in the following orders: [$100, $50, $20, $10, $5]. def dispenser(amount): # if statement to check if number entered is divisible by 5. If not, return with 0, if yes, continue code. if atm % 5 != 0: return [0, 0, 0, 0, 0] result = [] bill_types = [100, 50, 20, 10, 5] # starts with the starting amount being divided by each number in bill_types. for each_note in bill_types: note_counts = amount // each_note result.append(note_counts) # get the remainder and overwrite the previous. amount = amount % each_note return result # The code below is what will be given back as a sentence to the customer. print(f"You entered ${atm}: {dispenser(atm)}")

August 9, 2024 · 1 min · SourFox

Finding elements not in list

Haloo people! How long has it been since I’ve done a blog post? Welp, I’ve finished my long break and now it’s time to get back to work. Today, I’ll be writing a python program that prints the elements of one list (a) that are not in the other list (b) as a list. My conditions are: If the lists have the same elements, it will print an empty list. If the first list (a) is an empty list, it’ll print an empty list. An example - ...

February 4, 2024 · 2 min · SourFox

Assignment 3: Doubling

Today, I was given another assignment. (Which I wasn’t expecting.) Today’s assignment was to write a python program which had to meet the conditions: Write a Python proram that multiplies all the items in a list by the value of the variable factor. The program must print the list as the output. The program should allow multiplying the variable factor by a string in case the list contains strings. You may assume that the value of factor will be a positive integer. ...

October 18, 2023 · 4 min · SourFox