diff --git a/codedamn10.py b/codedamn10.py deleted file mode 100644 index 98ac789..0000000 --- a/codedamn10.py +++ /dev/null @@ -1,25 +0,0 @@ - - -""" -10) custom function - -""" - - - -# Finish the function that prints out your name - -def name(): - - - - - - -def main(): - name() - - - -if __name__ == "__main__": - main() diff --git a/codedamn11.py b/codedamn11.py deleted file mode 100644 index 9b6e095..0000000 --- a/codedamn11.py +++ /dev/null @@ -1,24 +0,0 @@ - - - -""" -11) function and docstring - - -""" - -# create a function goodbye that prints out "goodbye" -# and has a docstring - - - - -def main(): - goodbye() - - - -if __name__ == "__main__": - main() - - diff --git a/codedamn13.py b/codedamn13.py deleted file mode 100644 index d553eb2..0000000 --- a/codedamn13.py +++ /dev/null @@ -1,54 +0,0 @@ - -""" -13) Booleans conditions - - -""" - -# make the following eqivalent - -""" -eg. - -test = 4 != 3 # I made test Test 4 don't equal 3 -""" - - -no = 1 == # finish equivalence making no True - -nope = 3 != # finish equivalence making nope False - -maybe = 5 >= # finish equivalence making maybe True - - - - - - - - - - - - - - - -def main(): - if no == True: - print(f"no: passed test, got {no}, expected True") - else: - print(f"no: failed test, got {no}, expected True") - if nope == False: - print(f"nope: passed test, got {nope}, expected False") - else: - print(f"nope: failed test, got {nope}, expected False") - if maybe == True: - print(f"maybe: passed test, got {maybe}, expected True") - else: - print(f"maybe: failed test, got {maybe}, expected True") - - - -if __name__ == "__main__": - main() diff --git a/codedamn14.py b/codedamn14.py deleted file mode 100644 index b3fa7aa..0000000 --- a/codedamn14.py +++ /dev/null @@ -1,38 +0,0 @@ - -""" -14) reassign increment inplace - -""" - - -x = 4 - -x = x # make x equal 10 - -new = x # new equal 8 - -new new # use incrementing to increase new to 10 - -new new # use decrementing to decrease new to 5 - - - - - - - - -def main(): - if x == 10: - print(f"x: passed test, got {x}, expected 10") - else: - print(f"x: failed test, got {x}, expected 10") - if new == 5: - print(f"new: passed test, got {new}, expected 5") - else: - print(f"new: failed test, got {new}, expected 5") - - - -if __name__ == "__main__": - main() diff --git a/codedamn15.py b/codedamn15.py deleted file mode 100644 index e56a38a..0000000 --- a/codedamn15.py +++ /dev/null @@ -1,39 +0,0 @@ - - -""" -15) while loop - -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 print out like this -""" - -x = 10 - -# count down from 10 to 0, just like the example above -# fill in the head state with a condition -# fill in the body, you need two lines one to change value -# and eon to print - -while : - - - - - - -def main(): - pass - - - -if __name__ == "__main__": - main() diff --git a/codedamn16.py b/codedamn16.py deleted file mode 100644 index dddf2f6..0000000 --- a/codedamn16.py +++ /dev/null @@ -1,31 +0,0 @@ - - -""" -16) if / else - -""" - -# write an if / else if the following numbers are less than 10 -# uncomment one at a time to test your condition - -x = 11 -##x = 12 -##x = 8 - -if : # finish by writing condition here - print(f"Yes {x} is less than 10") -else: - print(f"no {x} is not less than 10") - - - - - - -def main(): - pass - - - -if __name__ == "__main__": - main() diff --git a/codedamn17.py b/codedamn17.py deleted file mode 100644 index c765b42..0000000 --- a/codedamn17.py +++ /dev/null @@ -1,35 +0,0 @@ - -""" -17) modulo operator - - -eg. r_1 = 3 % 2 # to assign a remainder of 1 -""" - -r_2 = 5 % # enter a number to assign a remainder of 2 - -r_5 = 11 % # enter a number to assign a remainder of 5 - -r_3 = 10 % # enter a number to assign a remainder of 3 - - - -def main(): - if r_2 == 2: - print(f"r_2: passed test, got {r_2} expected 2") - else: - print(f"r_2: failed test, got {r_2} expected 2 ") - if r_5 == 5: - print(f"r_5: passed test, got {r_5} expected 5") - else: - print(f"r_5: failed test, got {r_5} expected 5") - if r_3 == 3: - print(f"r_3: passed test, got {r_3} expected 3") - else: - print(f"r_3: failed test, got {r_3} expected 3") - - - - -if __name__ == "__main__": - main() diff --git a/codedamn18.py b/codedamn18.py deleted file mode 100644 index e291b62..0000000 --- a/codedamn18.py +++ /dev/null @@ -1,27 +0,0 @@ - - -""" -18) for loop - -iterate through list - - -""" - -grades = [81,76,96,93,95,100] - - -# write a for loop on grade that prints out if they are divisable by 3 -# code below - - - - - -def main(): - pass - - - -if __name__ == "__main__": - main() diff --git a/codedamn19.py b/codedamn19.py deleted file mode 100644 index 1bb35ee..0000000 --- a/codedamn19.py +++ /dev/null @@ -1,28 +0,0 @@ - - - - -""" -20) wrap previous for loop in function - - -""" - -grades = [81,76,96,93,95,100] - - -def divisable_by_3(l): - # write code below - - - - - - -def main(): - divisable_by_3(grades) - - - -if __name__ == "__main__": - main() diff --git a/codedamn2.py b/codedamn2.py deleted file mode 100644 index 534bbee..0000000 --- a/codedamn2.py +++ /dev/null @@ -1,41 +0,0 @@ - - - -"""2) variables types - -three type assignment""" - -# assign the following types - - - -name = # str -- string - -age = # int -- integer - -decimal = # float -- float - - - - - - - - - -def main(): - if type(name) == str: - print(f"{name} passed test") - else: - print(f"{name}: failed test") - if type(age) == int: - print(f"{age}: passed test") - else: - print(f"{age}: failed test") - if type(decimal) == float: - print(f"{decimal}: passed test") - else: - print(f"{decimal}: failed test") - -if __name__ == "__main__": - main() diff --git a/codedamn20.py b/codedamn20.py deleted file mode 100644 index 50e14ef..0000000 --- a/codedamn20.py +++ /dev/null @@ -1,35 +0,0 @@ - -""" - -20) range function - -3 -6 -9 -12 -15 -18 create a print out like this -""" - -# use a for loop and range function to create a print out like above -# code below - - - - - - - - - - - - - -def main(): - pass - - - -if __name__ == "__main__": - main() diff --git a/codedamn21.py b/codedamn21.py deleted file mode 100644 index 1f5e25f..0000000 --- a/codedamn21.py +++ /dev/null @@ -1,45 +0,0 @@ - -""" -21) slicing with step - - -""" - - - -letters = "abcdefghijk" - - -every_other = # assign every other letter from letters - -every_third = # assign every 3rd letter from letters - -first_3_every_other = # assign the three letter everyother 1 eg. ace - - - - - - - - - - -def main(): - if every_other == "acegik": - print(f"every_other: passed test, got {every_other} expected acegik") - else: - print(f"every_other: failed test, got {every_other} expected acegik") - if every_third == "adgj": - print(f"every_third: passed test, got {every_third} expected acegik") - else: - print(f"every_other: failed test, got {every_third} expected acegik") - if first_3_every_other == "ace": - print(f"every_other: passed test, got {first_3_every_other} expected acegik") - else: - print(f"first_3_every_other: failed test, got {first_3_every_other} expected acegik") - - - -if __name__ == "__main__": - main() diff --git a/codedamn22.py b/codedamn22.py deleted file mode 100644 index 53247ba..0000000 --- a/codedamn22.py +++ /dev/null @@ -1,30 +0,0 @@ - - -""" -22) input function - -""" - -# use an input function to ask for someones name and run srcipt - - -name = - - -print(f"Hi {name} nice to meet you") - - - - - - -def main(): - if len(name) > 0 and name.isalpha(): - print("name: passed test") - else: - print("name: failed test\nplease try again") - - - -if __name__ == "__main__": - main() diff --git a/codedamn23.py b/codedamn23.py deleted file mode 100644 index 93f1681..0000000 --- a/codedamn23.py +++ /dev/null @@ -1,34 +0,0 @@ - - -""" -23) input modules - -""" - - -# import the sys module - - - - - - - - - - - - - - -def main(): - try: - print(dir(sys)) - print("\nNice work!") - except: - print("Ooops, somethings wrong. Please try again") - - - -if __name__ == "__main__": - main() diff --git a/codedamn3.py b/codedamn3.py deleted file mode 100644 index 737aef6..0000000 --- a/codedamn3.py +++ /dev/null @@ -1,39 +0,0 @@ - - -""" -3) operators - -""" - -x = 2 -y= 26 -z = 4 - -m = # multiply y by 17 -d = # add 14 to z -t = # subtract 12 from x - - - - - - - - - -def main(): - if m == 442: - print(f"m passed test, got {m} expected 442") - else: - print(f"m failed test, got {m} expected 442") - if d == 18: - print(f"d passed test, got {d} expected 18") - else: - print(f"d failed test, got {d} expected 18") - if t == -10: - print(f"t passed test, got {t} expected -10") - else: - print("t failed test, got {t} expected -10") - -if __name__ == "__main__": - main() diff --git a/codedamn4.py b/codedamn4.py deleted file mode 100644 index d773e3f..0000000 --- a/codedamn4.py +++ /dev/null @@ -1,37 +0,0 @@ - - -""" -4) Index and Slicing - -""" - -word = "CatMat" - -first = # assign the first letter of word with indexing -third = # assign the third letter of word with indexing -f_3 = # assign the first three letters word with slicing - - - - - - - -def main(): - if first == "C": - print(f"first: passed test, got {first}, expected C") - else: - print(f"first: failed test, got {first}, expected C") - if third == "t": - print(f"third: passed test, got {third}, expected t") - else: - print(f"third: failed test, got {third}, expected t") - if f_3 == "Cat": - print(f"f_3: passed test, got {f_3}, expected Cat") - else: - print(f"f_3: failed test, got {f_3}, expected Cat") - - - -if __name__ == "__main__": - main() diff --git a/codedamn7.py b/codedamn7.py deleted file mode 100644 index 5bc4b98..0000000 --- a/codedamn7.py +++ /dev/null @@ -1,27 +0,0 @@ - - -""" -7) syntax/variable rules - -""" - -# fix what's wrong - -4_test = 5 - -print("hello) - -test 1 = 97 - - - - - - -def main(): - pass - - - -if __name__ == "__main__": - main() diff --git a/script.py b/script.py index 4d13505..463acc8 100644 --- a/script.py +++ b/script.py @@ -1,23 +1,17 @@ -""" -18) for loop -iterate through list -""" - -grades = [81,76,96,93,95,100] - - -# write a for loop on grade that prints out if they are divisable by 3 -# code below - - - +""" +wrap previous for loop in function -def main(): - pass +""" +grades = [81,76,96,93,95,100] # don't change -if __name__ == "__main__": - main() +def divisible_by_3(l): + threes = [] + # write code below, use the code from previous lesson + : # here + : # here + threes.append(grade) # don't change + return threes # don't change