import random a = random.randint(1,101) b = random.randint(1,101) c = random.randint(1,101) d = random.randint(1,101) print(a,b,c,d) def my_function1(x=20): if x >19: return ("banana","cherry","apple") else: return (14,21,33) if a>b and c < d: thislist= [] for i in range(10): thislist.append("ListSucceeded") thislist[4] = "okay that worked" print(thislist) elif a < b or not c > d: print("Tuple function succeeded") print(my_function1(a)) else: print(a,b,c,d,"Mission Accomplished") """ We had a little fun in that section. We have a function that contains an if statement with a tuple inside. We also have two conditional if statements, with 4 different possible outcomes. We utilitized the or keywords, in conjunction with the not keywords which ends up giving us an exclusive or situation. So the statement is that if a is less than b or c is not greater than d.... Acutally that does not setup an exclusive or situation. It only just reverses the meaning of the statement, so instead of greater than, we get a less than. In order to setup an exclusive or I would have to use and, in conjuntion with not I think., Or perhaps, even two of them stacked on top of eachother. If I ever need to use this type of logic I will have to research it's use, and think about it for a few minutes.""" """ Let us now continue with if and while loops. Lets see what other of our previous lessons we can incoroporate into our loops so that we can interpret this stuff into a longer term memory.""" i = 1 while i < a : print("bonus damage") if i%3 == 0: print("CRITICAL STRIKE!") break i += 22 """I incorporated the modulus into this while loop, so that I can see how that works. Seems to work nicely. Since a is random sometimes a critical strike will be accomplished and sometimes not""" i = 1 while i < b: if i%3 == 0: i += 7 print("You hid from one enemy") continue print("A new enemy joins the fight against you") i += 7 fruits = ["apple", "banana", "pear", "orange"] fruits.append("cherry") for x in fruits: print(x) z = "banana" for x in "banana": if x == "n": break print(x) for x in range(0,7,2): print(x) for x in range(6): print(x) else: print("This else statement executed after the loop finished") adjective = ("tuple1","tuple2","tuple3") for x in adjective: for y in fruits: print(x,y) """A lambda function is a small anyonymous function that can take any number of arguments, but can only return one restult.""" """For example this lambda function adds ten to the number passed in as an argument, and can print the result.""" x = lambda x : x + 10 print(x(22)) x = lambda x : x *12 / 3 print(x(9)) y = 2 x = lambda x,y: x*y print(x(9,y)) def my_function1(n): return lambda x : x * n doubler = my_function1(2) print(doubler(8)) x = ["red","blue"] y = ["green","yellow"] x.extend(y) print(x) print(y) x.clear() print(x) #This now throws an error out side of range x[0] = "blue" """One thing I learned while doing this is about positional arguments. Classes always expect a positional argument. So if I give none, it will cause an error and say it was expecting one. If i I give too many it will again cause an error saying that it expects, two positional arguments but only 1 was expected""" class playtime: def __init__(self,x,y,z): for i in range(3): print(x,y,x,"Success") def testingtime(self): print("poppa big dick") playtime(x,y,z) playtime(x,y,z) playtime(x,y,z) playtime(x,y,z) playtime(x,y,z) playtime(x,y,z) playtime(x,y,z).testingtime() def returnmulti(): x = 10 y = 20 return x,y x,y = returnmulti() print(x,y) x = [3,5,7,8,9,5,3] for i in x: print(i) abc4 = 0 for i in range(5): abc4 +=1 print(abc4) x = [] x.append(0) x[0].output = 5 print(x[0].output)