Skip to content

Commit e7e5f7d

Browse files
committed
Adding Lab06 plus Notes
1 parent 68abb95 commit e7e5f7d

File tree

12 files changed

+388
-0
lines changed

12 files changed

+388
-0
lines changed
File renamed without changes.

code/kaceyb/python/lab06/lab_06.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Let's convert a dollar amount into a number of coins. The input will be the total amount, the output will be the number of quarters, dimes, nickles, and pennies.
2+
# Always break the total into the highest coin value first, resulting in the fewest amount of coins. For this, you'll have to use floor division //,
3+
# which throws away the remainder. 10/3 is 3.333333, 10//3 is 3.
4+
5+
# Welcome to the Change Maker 5000 (tm)
6+
# Enter a dollar amount: 1.36
7+
# 5 quarters, 1 dime, and 1 penny
8+
# Would you like make more change? yes
9+
# Enter a dollar amount: 0.67
10+
# 2 quarters, 1 dime, 1 nickel, 2 pennies
11+
# Would you like make more change? no
12+
# Have a good day!
13+
14+
# Version 2 (optional)
15+
16+
# Instead of hard-coding the coins, store them in a list of tuples. This way you can make custom coins.
17+
18+
# coins = [
19+
# ('half-dollar', 50),
20+
# ('quarter', 25),
21+
# ('dime', 10),
22+
# ('nickel', 5),
23+
# ('penny', 1)
24+
# ]
25+
26+
27+
coins = [
28+
("half-dollar", 50),
29+
("quarter", 25),
30+
("dime", 10),
31+
("nickel", 5),
32+
("penny", 1),
33+
]
34+
35+
while True:
36+
37+
dollar_amount = "" # dollar_amount needs to be defined before used further on, dollar_amount equals empty string
38+
print("Welcome to the Change Maker 5000")
39+
while (
40+
type(dollar_amount) != float
41+
): # while the type of dollar_amount does NOT equal a float
42+
dollar_amount = input(
43+
"Enter a dollar amount: $"
44+
) # dollar_amount equals user-input of dollar_amount as a "string" all inputs are strings
45+
try:
46+
dollar_amount = float(
47+
dollar_amount
48+
) # try to convert dollar_amount to a float
49+
# print(type(dollar_amount))
50+
except:
51+
print(
52+
f"Please enter a valid float: example is '1.57'"
53+
) # goes into this line when the user enters an invalid input
54+
dollar_amount = dollar_amount * 100
55+
half_dollars = dollar_amount // 50
56+
# dollar_amount = dollar_amount-(half_dollars * 50)
57+
dollar_amount = dollar_amount % 50
58+
# print(dollar_amount)
59+
# print(half_dollars)
60+
61+
quarters = dollar_amount // 25
62+
dollar_amount = dollar_amount - (quarters * 25)
63+
# print(quarters)
64+
#
65+
dimes = dollar_amount // 10
66+
dollar_amount = dollar_amount - (dimes * 10)
67+
# print(dimes)
68+
69+
nickels = dollar_amount // 5
70+
dollar_amount = dollar_amount - (nickels * 5)
71+
# print(nickels)
72+
73+
# print('total before', dollar_amount)
74+
75+
pennies = dollar_amount / float(1)
76+
# print('number of pennies', pennies)
77+
penny_amount = pennies * float(1)
78+
dollar_amount = dollar_amount - penny_amount
79+
# print(dollar_amount)
80+
# print(pennies)
81+
82+
# print(f"{int(half_dollars)}:Half Dollars {int(quarters)}:Quarters {int(dimes)}:Dimes {int(nickels)}:Nickles {int(pennies)}:Pennies")
83+
statement = ""
84+
if half_dollars > 0:
85+
statement = statement + " " + str(int(half_dollars)) + " " + "Half Dollars"
86+
87+
if quarters > 0:
88+
statement = statement + " " + str(int(quarters)) + " " + "Quarters"
89+
90+
if dimes > 0:
91+
statement = statement + " " + str(int(dimes)) + " " + "Dimes"
92+
93+
if nickels > 0:
94+
statement = statement + " " + str(int(nickels)) + " " + "Nickels"
95+
96+
if pennies > 0:
97+
statement = statement + " " + str(int(pennies)) + " " + "Pennies"
98+
99+
print(statement)
100+
101+
done = input("Would you like to make more change? yes or no: ").lower()
102+
103+
if done == "no":
104+
print("Goodbye")
105+
quit()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
red, green, yellow, blue, indigo, chartuce
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
green
2+
yellow
3+
indigo
4+
chartuce
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Adding content to file
2+
MORE TEXT
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Legacy Method
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# with open('example.txt', 'a') as file:
2+
# text = file.write('\nMORE TEXT')
3+
# print(text)
4+
5+
# file = open('example2.txt', 'w')
6+
# text = file.write('Legacy Method')
7+
# print(text)
8+
# file.close()
9+
10+
# with open('colors.txt') as file:
11+
# colors = file.read()
12+
13+
# colors = file.read().split()
14+
# print(colors)
15+
16+
# with open('colors.txt', 'w') as file:
17+
# text = file.write()
18+
# print(text)
19+
20+
# import datetime
21+
22+
#read file
23+
24+
# start = datetime.datetime.now()
25+
# with open('phonebook.txt') as file:
26+
# phone_book = file.read()
27+
# end = datetime.datetime.now()
28+
29+
# print(f'Your file loaded in {end-start}')
30+
31+
# with open('phonebook.txt', 'w') as file:
32+
# text = file.write('')
33+
# print(text)
34+
35+
# with open('phonebook.txt') as file:
36+
# phone_book = file.read()
37+
38+
# phone_book = phone_book.split('\n')
39+
# name = input('Lookup name: ')
40+
41+
# found_entry = False
42+
# for entry in phone_book:
43+
# if name.lower() in entry.lower():
44+
# print(entry)
45+
# found_entry = True
46+
47+
# if not found_entry:
48+
# print('Contact not found')
49+
# name = input('Enter new contact name: ')
50+
# phone_number = input(f'Enter the number for : {name}')
51+
52+
# phone_book.append(name + " " + phone_number)
53+
54+
# phone_book.sort()
55+
# with open('phonebook2.txt', 'w') as file2:
56+
# file2.write('\n'.join(phone_book))
57+
58+
59+
# print(type(phone_book))
60+
# print(phone_book)
61+
# def Convert(lst):
62+
# res_dct = {lst[i]: lst[i + 1] for i in range (0, len(lst), 2)}
63+
# return res_dct
64+
65+
# with open('phonebook.txt', 'r') as file:
66+
# color = file.read()
67+
# color = color.split('\n')
68+
# color = Convert(color)
69+
# print(color)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from urllib import response
2+
import requests
3+
4+
# response = requests.get('https://google.com')
5+
# print(response)
6+
# print(type(response))
7+
# print(response.text)
8+
# print(response.status_code)
9+
10+
# response = requests.get('https://api.chucknorris.io/jokes/random')
11+
12+
# print(response)
13+
# print(response.text)
14+
15+
# joke = response.text
16+
# joke = response.json() #python friendly dictionary
17+
# # print(joke)
18+
# print(joke['value'])
19+
20+
21+
# response = requests.get('https://api.chucknorris.io/jokes/categories')
22+
# print(response.json())
23+
24+
# categories = response.json()
25+
26+
# # for category in categories:
27+
# # print(category)
28+
29+
# for i in range(len(categories)):
30+
# print(i, categories[i])
31+
32+
# choice = int(input('Select a category: '))
33+
34+
# query = {
35+
# 'category': categories[(choice)]['value']
36+
# }
37+
38+
# # response = requests.get(f'https://api.chucknorris.io/jokes/random?category={categories[choice]}')
39+
# response = requests.get('https://api.chucknorris.io/jokes/random', 'params=query')
40+
41+
# print(response.text)
42+
43+
44+
import requests
45+
url = 'https://ghibliapi.herokuapp.com/films'
46+
response = requests.get(url)
47+
# print(response.text)
48+
data = response.json()
49+
# print(data[0]['title'])
50+
for film in data:
51+
print(film['title'])
52+
print(film['release_date'])
53+
print(film['description'])
54+
55+
56+
print('-'*10)
57+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Ana Runolfsdottir 1-651-947-5883
2+
Frances Hodkiewicz (812) 644-2602
3+
Alice Hills DVM 1-701-918-2306
4+
Dr. Ludwig Wehner V 770-863-2764
5+
Prof. Gianni Larson 1-628-664-6844
6+
Alessia Donnelly 14095791424
7+
Darrell Schultz (361) 913-5529
8+
Prof. Maeve Reichel Jr. 1-463-520-6964
9+
Prof. Marley Ward 1-620-329-7156
10+
Dell Rice II 12708789575
11+
Mr. Norval Reynolds II 1-423-689-8828
12+
Glennie Eichmann 1-703-288-7625
13+
Garett Stokes Sr. (540) 976-8024
14+
Abbigail Klocko 657-673-2829
15+
Josue Wintheiser 13259951373
16+
Miss Noemy Feeney PhD 734-757-2080
17+
Prof. Hettie Kunde 201.474.0600
18+
Mr. Oda Tremblay 1-775-780-6154
19+
Mrs. Bernadette Kris DVM 808.446.9460
20+
Thea Terry 1-432-761-8897
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Abbigail Klocko 657-673-2829
2+
Alessia Donnelly 14095791424
3+
Alice Hills DVM 1-701-918-2306
4+
Ana Runolfsdottir 1-651-947-5883
5+
Darrell Schultz (361) 913-5529
6+
Dell Rice II 12708789575
7+
Denise 55649897654
8+
Dr. Ludwig Wehner V 770-863-2764
9+
Frances Hodkiewicz (812) 644-2602
10+
Garett Stokes Sr. (540) 976-8024
11+
Glennie Eichmann 1-703-288-7625
12+
Josue Wintheiser 13259951373
13+
Miss Noemy Feeney PhD 734-757-2080
14+
Mr. Norval Reynolds II 1-423-689-8828
15+
Mr. Oda Tremblay 1-775-780-6154
16+
Mrs. Bernadette Kris DVM 808.446.9460
17+
Prof. Gianni Larson 1-628-664-6844
18+
Prof. Hettie Kunde 201.474.0600
19+
Prof. Maeve Reichel Jr. 1-463-520-6964
20+
Prof. Marley Ward 1-620-329-7156
21+
Thea Terry 1-432-761-8897

0 commit comments

Comments
 (0)