diff --git a/beginner_python/01-numbers.py b/beginner_python/01-numbers.py index 67fb283..6ee8043 100644 --- a/beginner_python/01-numbers.py +++ b/beginner_python/01-numbers.py @@ -20,7 +20,7 @@ print("Here is a floor version (crop decimal):", 20 // 3) #6 -result = 5**2 #raising a number to a power (5^) +result = 5**2 #raising a number to a power (5^2) print(result) #You can use round instead. diff --git a/beginner_python/05-logic-and-if.py b/beginner_python/05-logic-and-if.py index c1f7d20..0fb47f9 100644 --- a/beginner_python/05-logic-and-if.py +++ b/beginner_python/05-logic-and-if.py @@ -5,7 +5,7 @@ #You must first understand booleans. #They are either True or False (these are both keywords) -# + happy = True print(happy) @@ -25,18 +25,31 @@ my_grades = [100, 100, 100] your_grades = [100, 100, 1] print("Same grade?", my_grades == your_grades) #false +print(id(my_grades)) +print(id(your_grades)) +# Watch out and remember alias vs copying a list and deepcopying it!!!!! + + +# HERE we are manipulating the "VALUE" of the your_grades list variable. +# What's on the left of the assignment operator your_grades = [100, 100, 100] print("Same grade?", my_grades == your_grades) #true - +print(id(my_grades)) +print(id(your_grades)) #in some languages, == compares by memory address to see if same object #this is done in python using is. #This is known as an identity comparison print("are grades the same object?", my_grades is your_grades) #false + +# HERE we are manipulating the "VARIABLE ITSELF NOT IT'S VALUE" of the your_grades list variable. +# What's on the RIGHT of the assignment operator + my_grades = your_grades print("are grades the same object?", my_grades is your_grades) #true - +print(id(my_grades)) +print(id(your_grades)) #You can also do order testing for strings #Read ABC comes before BCD? print("A before B?", "ABC" < "BCD") @@ -76,10 +89,10 @@ ########## if elif else ########## -if age > 100: - print("You're old") -elif age > 120: +if age > 120: print("How are you even alive?") +elif age > 100: + print("You're old") else: print("You may have some years left in you") @@ -131,10 +144,13 @@ temp_outside = 50 pool_heated = False +# nafy el nafy esbat!!!!!! +range() if temp_outside < 60 and not pool_heated: print("Don't go swimming!") #this can be confusing, so it might be best to read it as english #however, logically... pool_heated is false so not pool_heated is true. #therefore, both sides are true. +# diff --git a/beginner_python/06-loop-basics.py b/beginner_python/06-loop-basics.py index 643d310..05108f4 100644 --- a/beginner_python/06-loop-basics.py +++ b/beginner_python/06-loop-basics.py @@ -26,9 +26,9 @@ for language in languages: print(language, end =" ") print() -#can end with newline tfor future prints +#can end with newline for future prints -#You could alternatively use end="\t" or end="" or whatever you want. +#You could alternatively use end=" " or end="" or whatever you want. #You might be confused why we have to put end and not just: print("DOEN'T AFFECT END", " ") @@ -52,7 +52,7 @@ #for range(10), we get 0-9: for i in range(10): - print(i, end=" ") + print(i, end="-") print() #Important: the value to end at is never part of the range. @@ -65,6 +65,7 @@ #We can count 1-10 instead of 0-9 if desired: for i in range (1, 11): print(i, end=" ") + print() #We can start anywhere and end anywhere diff --git a/beginner_python/sandbox_4.py b/beginner_python/sandbox_4.py new file mode 100644 index 0000000..5160f97 --- /dev/null +++ b/beginner_python/sandbox_4.py @@ -0,0 +1,20 @@ +#happy = True + +#if happy == True: +# print("Awesome!") + +print("What is your age?") +age = int(input()) +#can_drink = age > 21 #another age variable that can be assigned so we can check against it. +#print(can_drink) + +if 65 > age > 21: + print("Welcome to our app, can drink for sure!!") +elif age < 21: + print('Can\'t drink you\'re under the age') +elif age > 65: #a catch-all statement + print("You're a senior citizen") +else: + print("Super special!") + +print("Thaaaaanks!") \ No newline at end of file