-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay13_Debugging_Code.py
More file actions
56 lines (47 loc) · 2 KB
/
Day13_Debugging_Code.py
File metadata and controls
56 lines (47 loc) · 2 KB
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
############DEBUGGING#####################
def my_function() -> None:
for i in range(1, 21):
# for i in range(1, 20):
# this will NOT reach 20 as last limit not included.
# We want to print at i=20 so i let it reach 20.
if i == 20:
print("You got it")
my_function()
# # Reproduce the Bug
# from random import randint
# dice_images = ["❶", "❷", "❸", "❹", "❺", "❻"]
# dice_num = randint(1, 6)
# print(dice_images[dice_num-1])#print(dice_images[dice_num]) indices are 0-5 not 1-6 as we want. so -1
# # Play Computer
# year = int(input("What's your year of birth? "))
# if year > 1980 and year < 1994:
# print("You are a millenial.")
# elif year >= 1994:#1994 ke liye let it be gen z
# print("You are a Gen Z.")
# else: print("You are neither Gen Z, nor a Millenial.")#added this else statement.
# # Fix the Errors
# age = int(input("How old are you? "))#age = input("How old are you? ") won't let us compare int with str so converted age to int
# if age >= 18:#if age > 18, >=18 makes more sense to me.
# print(f"You can drive at age {age}.")#print("You can drive at age {age}.") without indentation. Fixed indentation and made it a formatted string to print variable age
# else: print(f"You cannot drive at age {age}.")#added else statement.
# #Print is Your Friend
# pages = 0
# word_per_page = 0
# pages = int(input("Number of pages: "))
# word_per_page = int(input("Number of words per page: "))#there was == here instead of = and needed print statements.
# total_words = pages * word_per_page
# print(total_words)
# #Use a Debugger: Visualise on pythontutor.com it is legit great!!!
# def mutate(a_list): So many bugs baap re
# b_list = []
# for item in a_list:
# new_item = item * 2
# b_list.append(new_item)
# print(b_list)
# def mutate(a_list):
# b_list = []
# for item in a_list:
# new_item = item * 2
# b_list.append(new_item)
# print(b_list)
# mutate([1,2,3,5,8,13])