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

Commas replaced by dots

It’s been a long time since i’ve done a blog post. I wonder why…. Welp, today I’ve got an assignment, today’s one is to write a python program that prints a version of the strings with all commas replaced by dots. Like this. Example - Input Output "Hello, World!" "Hello. World!" "725,000" "725.000" First, I’m going to do the 1st one. I’m going to assign it to a variable called string. ...

December 26, 2023 · 1 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

Assignment 1: Using Length and String

Today, I was given an assignment. My assignment wanted me to write a Python program that pints the length of a string. This is what I had to print out: The length of "" is 0. The length of "H" is 1. The length of "Hello" is 5. The length of "Amazing" is 7. To do this, I have a plan in my mind which is: Step 1. Find out what I’m going to use. ...

October 15, 2023 · 3 min · Soure Fox