@culpower/

udemy_bootcamp

Python

Contains code for course

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# Use this repl for ongoing coding scripts # for Udemy Modern Py3 Bootcamp


# print("How many kilometers did you run today?")
# kms = input()
# print("OK, you said " + str(kms))
# miles = int(kms)/1.60934
# miles = round(miles,2)
# print("Sweet, that is " + str(miles) + " miles")

# color = input("What's your favorite color? ")
# print("You said " + color)

# # NO TOUCHING ======================================
# from random import randint
# num = randint(1, 1000) #picks random number from 1-1000
# # NO TOUCHING ======================================

# # YOUR CODE GOES HERE vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# print(num)
# if num % 2 == 0:
#     print("even")
# else:
#     print("odd")

# # YOUR CODE GOES HERE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# # Truthiness and Falsyness (sp?)
# animal  = input("enter your favorite animal ")

# if animal:
#     print(animal + " is my favorite, too!")
# else:
#     print("YOU DIDN'T SAY ANYTHING!")

# # Values that resolve to True are "truthy", and values that 
# # resolve to False are "falsy". So if there is a value in a 
# # variable, like animal above, it is truthy.    
# # Other things that are falsy: empty objects, empty strings,
# # None, and zero. Everything else is truthy.


# # bouncer.py
# age = input("How old are you: ")
# if age: # this forces truthiness, otherwise error (like with blank response)
#     age = int(age)
#     if age >= 18 and age < 21:
#         print("You can enter, but you need a wristband!") 
#     elif age >= 21:
#         print("You are good to enter and can drink!")
#     else:
#         print("You can't come in, little one! :(")
# else:
#     print("Please enter an age!")

# if age and (age >= 18 and age < 21):
#     print ("You can enter but need a wristband")

# # cleaner version:
# age = input("How old are you: ")
# if age: # this forces truthiness, otherwise error (like with blank response)
#     age = int(age)
#     if age >= 21:
#         print("You are good to enter and can drink!") 
#     elif age >= 18:
#         print("You can enter, but you need a wristband!")
#     else:
#         print("You can't come in, little one! :(")
# else:
#     print("Please enter an age!")

# if am_hungry:
#     print("get food")
# else:
#     print("go learn Python")
# 
#==========================================================
# # My Rock Paper Scissors game 
# # Basic version: 2 human players
#==========================================================
# 
# print("...Rock...")
# print("...Paper...")
# print("...Scissors...")
# player1 = input("Make a choice (rock, paper, scissors) ")
# player2 = input("Make a choice (rock, paper, scissors) ")
# print("SHOOT!")

# if player1 == player2:
#     print("It's a draw. Try again.")
# elif player1 == "rock" and player2 == "paper":
#     print(f"{player2} beats {player1}. Player2 wins.")
# elif player1 == "rock" and player2 == "scissors":
#     print(f"{player1} beats {player2}. Player1 wins.")
# elif player1 == "paper" and player2 == "rock":
#      print(f"{player1} beats {player2}. Player1 wins.")   
# elif player1 == "paper" and player2 == "scissors":
#      print(f"{player2} beats {player1}. Player2 wins.")   
# elif player1 == "scissors" and player2 == "rock":
#       print(f"{player2} beats {player1}. Player2 wins.")     
# elif player1 == "scissors" and player2 == "paper":
#       print(f"{player1} beats {player2}. Player1 wins.") 
# else:
#     print("It's not that hard...choose one of the 3.")
#     
#==================================================
# # Rock Paper Scissors game with some improvements 
# # Basic version: 2 human players
#==================================================
# 
# print("...Rock...")
# print("...Paper...")
# print("...Scissors...")
# player1 = input("Player1, make a choice (rock, paper, scissors) ")
# print("***NO CHEATING!***\n" * 50) # the \n puts each print on one line
# player2 = input("Player2, make a choice (rock, paper, scissors) ")
# print("SHOOT!")

# if player1 == player2:
#     print("It's a draw. Try again.")
# elif player1 == "rock":
#     if player2 == "paper":
#         print(f"{player2} beats {player1}. Player2 wins.")
#     elif player2 == "scissors":
#         print(f"{player1} beats {player2}. Player1 wins.")
# elif player1 == "paper":
#     if player2 == "scissors":
#         print(f"{player2} beats {player1}. Player2 wins.")   
#     elif player2 == "rock":
#         print(f"{player1} beats {player2}. Player1 wins.")   
# elif player1 == "scissors":
#     if player2 == "rock": 
#         print(f"{player2} beats {player1}. Player2 wins.")   
#     elif player2 == "paper":
#         print(f"{player1} beats {player2}. Player1 wins.")     
# else:
#     print("It's not that hard...choose one of the 3.")

# # Replaced player1 with a random component for the computer 
# from random import *

# computer = randint(1,3)
# if computer == 1:
#     player1 = "rock"
# elif computer == 2:
#     player1 = "paper"
# else:
#     player1 = "scissors"
# print(player1)

# print("...Rock...")
# print("...Paper...")
# print("...Scissors...")
# player2 = input("Player2, make a choice (rock, paper, scissors) ").lower() # the .lower() handles case for when input uses caps
# print("SHOOT!")

# if player1 == player2:
#     print("It's a draw. Try again.")
# elif player2 == "rock":
#     if player1 == "paper":
#         print(f"{player1} beats {player2}. Player1 wins.")
#     elif player1 == "scissors":
#         print(f"{player2} beats {player1}. Player2 wins.")
# elif player2 == "paper":
#     if player1 == "scissors":
#         print(f"{player1} beats {player2}. Player1 wins.")   
#     elif player1 == "rock":
#         print(f"{player2} beats {player1}. Player2 wins.")   
# elif player2 == "scissors":
#     if player1 == "rock": 
#         print(f"{player1} beats {player2}. Player1 wins.")   
#     elif player1 == "paper":
#         print(f"{player2} beats {player1}. Player2 wins.")     
# else:
#     print("It's not that hard...choose one of the 3.")

# for x in range(1,10):
#     print(x*x)

# for letter in "coffee":
#     print(letter*10)

# for r in range(7,0,-1):
#     print(r)

# for nums in range(1,5):
#     print(nums)

# x = 0
# for i in range(11,21,2):
#     x = x + i
#     print(x)

# times = input("How many times do have to tell you? ")
# for i in range(int(times)):
#     print("CLEAN UP YOUR ROOM!")


# # EXERCISE (bookmarked)
# # (My version)
# for i in range(1,21):
#     if i == 4 or i == 13:
#         print(f"{i} is unlucky")
#     elif i % 2 == 0:
#         print(f"{i} is even")
#     else:
#         print(f"{i} is odd")

# # (Instructor tweak)
# for i in range(1,21):
#     if i == 4 or i == 13:
#         state = "unlucky"
#     elif i % 2 == 0:
#         state = "even"
#     else:
#         state = "odd"
#     print(f"{i} is {state}")
    
# num = 1
# while num < 11:
#     print(num)
#     print("\U0001f600")
#     num += 1 

# # While loop exercise
# x = 1
# while x < 11:
#     print("  :)  " * x)    
#     x += 1 
 
# for x in range(1,11):        
#     print("  :)  " * x)

# # Nested version (instructor)
# for x in range(3):
#     for x in range(1,11):        
#         print("  :)  " * x)

# # Try to center the smileys
# #Yayyy! figured it out!#######################
# x = 1
# while x < 20:
#     print((" " * (20-x) ) + (":)" * x))
#     x += 2 

# # Sister game of "Stop copying me!"
# me = ''
# print("How is it going? ") # her
# while me != "Stop copying me!":
#     her = print(me)
#     me = input()
# print("UGH FINE YOU WIN")

# # This works, but it's ugly
# me = ''
# her = ''
# print("How is it going? ") # her
# while me != "Stop copying me!":
#     me = input()
#     if me != "Stop copying me!":
#         print(me)    
# print("UGH FINE YOU WIN")

# Instructor version 1:
# msg = input("Say somthing ")
# while msg != "stop copying me":
#     print(msg)
#     msg = input()
# print("UGH FINE YOU WIN")

# # Instructor version 2:
# msg = input("Say somthing")
# while msg != "stop copying me":
#     msg = input(f"{msg}\n")
# print("UGH FINE YOU WIN")

# while True:
#     command = input("Type 'exit' to exit ")
#     if (command == "exit"):
#         break

# for x in range(2, 33):
#     print(x)
#     if x == 3:
#         break
##============================================
## Guessing Game mini project
##============================================
# import random as rd
# random_num = rd.randint(1,10)

# # player_num = None
# while True:
#     player_num = int(input("Give a number from 1 to 10 "))
#     if player_num > random_num:
#         print("Too high. Guess again. ")
#     elif player_num < random_num:
#         print("Too low. Guess again. ")
#     else:
#         print("You won!! ")
#         again = input("Want to play again? (y/n)")
#         if again == "y":
#             random_num = rd.randint(1,10)
#             player_num == None
#         else:
#             print("OK Bye")  
#             break

# my_stuff = ["keys", "phone", "glasses", 3.14, "pi"]
# print(my_stuff)

# # Define nums 
# r = range(0,100)
# nums = list(r) 
# print(nums)
        
# instructors = []
# instructors.extend(["Colt","Blue","Lisa"])

# instructors.pop()
# print(instructors)
# instructors.pop(0)
# print(instructors)
# instructors.insert(0,"Done")
# print(instructors)
# instructors[::1]
# print(instructors)
# colors = ["red", "orange", "yellow", "green", "blue"]
# print(colors)
# colors[1][::-1]
# print(colors)
# matrix = [[num for num in range(0,10)] for val in range(0,10)]
# print(matrix)

# artist = {
#     "first": "Neil",
#     "last": "Young"
# }
# print(artist)
# full_name = artist["first"] + ' ' + artist["last"]
# print(full_name)

# This code picks a random food item:
# from random import choice #DON'T CHANGE!
# food = choice(["cheese pizza", "quiche","morning bun","gummy bear","tea cake"]) #DON'T CHANGE!

#DON'T CHANGE THIS DICTIONARY EITHER!
# bakery_stock = {
#     "almond croissant" : 12,
#     "toffee cookie": 3,
#     "morning bun": 1,
#     "chocolate chunk cookie": 9,
#     "tea cake": 25
# }

# YOUR CODE GOES BELOW:
# if food in bakery_stock:
#     print(str(bakery_stock[food]) + " left")
# else:
#     print("We don't make that")

# new dictionary = dict.fromkeys(alist[])

#DO NOT TOUCH game_properties!
# game_properties = ["current_score", "high_score", "number_of_lives", "items_in_inventory", "power_ups", "ammo", "enemies_on_screen", "enemy_kills", "enemy_kill_streaks", "minutes_played", "notifications", "achievements"] 

# Use the game_properties list and dict.fromkeys() to generate a dictionary with all values set to 0. Save the result to a variable called initial_game_state

# initial_game_state = dict.fromkeys(game_properties, 0)
# print(initial_game_state)

inventory = {'croissant': 19, 'bagel': 4, 'muffin': 8, 'cake': 1} #DON'T CHANGE THIS LINE!

# Make a copy of inventory and save it to a variable called stock_list USE A DICTIONARY METHOD
stock_list = {}
stock_list.update(inventory)
# a better way:
stock_list = inventory.copy()

# add the value 18 to stock_list under the key "cookie"
stock_list.update({'cookie': 18})

# remove 'cake' from stock_list USE A DICTIONARY METHOD
stock_list.pop('cake')

print(stock_list)