Hacks 1:

  1. Iteration: an algorithm that runs repeatedly until a condition is met.
  2. Example of iteration:
    1. put cereal in bowl
    2. put milk in bowl
    3. put a spoon in the bowl
    4. wait till cereal is soggy
    5. eat the cereal until bowl is empty
    6. once bowl is empty => end
strawberries = 8

while (strawberries < 9):
    print("you have: " + str(strawberries) + " strawberries left!")
    strawberries = strawberries - 1
    if (strawberries == 0):
        print("you have: " + str(strawberries) + " strawberries left!")
        break
you have: 8 strawberries left!
you have: 7 strawberries left!
you have: 6 strawberries left!
you have: 5 strawberries left!
you have: 4 strawberries left!
you have: 3 strawberries left!
you have: 2 strawberries left!
you have: 1 strawberries left!
you have: 0 strawberries left!

hacks 2:

  1. iteration statements are basically statements that loop
num = 10
for i in range(num):
    print(num - i)
10
9
8
7
6
5
4
3
2
1

Hacks 3, 4:

list = 3

while list <= 81:
    print(list)
    list += 13
3
16
29
42
55
68
81
import getpass, sys
import random

def ask_question (question, answer):

    print(question)
    ans = input(question)
    print(ans)
   
    if ans == answer:
        print("Correct!")
        return 1

    else:
        print("Wrong")
        return 0

question_list = ["What allows a value to be inserted into a list at index i?" , "What allows an element at index i to be deleted from a list?" , "What returns the number of elements currently in a specific list?" , "What allows a value to be added at the end of a list?"]
answer_list = ["index()", "remove()", "length()" , "append()"]

# Set points to 0 at the start of the quiz
points = 0

# If the length of the quiz is greater than 0, then random questions will be chosen from the "question_list" set
while len(question_list) > 0:
    index = random.randint(0, len(question_list) - 1)
    
# The points system where a point is rewarded for each correct answer    
    points = points + ask_question(question_list[index], answer_list[index])
    
# If a question or answer has already been used, then it shall be deleted    
    del question_list[index]
    del answer_list[index]

# Calculating score using the points system and dividing it by the total number of questions (6)
score = (points / 4)

# Calculating the percentage of correct answers by multiplying the score by 100
percent = (score * 100)

# Printing the percentage, and formatting the percentage in a way where two decimals can be shown (through "{:.2f}")
print("{:.2f}".format(percent) + "%")

# Adding final remarks based upon the users given scores
if points >= 5:
         print("Your total score is: ", points, "out of 4. Amazing job!")

elif points == 4:
         print("Your total score is: ", points, "out of 4. Not too bad, keep on studying! " )

else:
         print("Your total score is: ", points, "out of 4. Its alright, better luck next time!")
What returns the number of elements currently in a specific list?
length()
Correct!
What allows an element at index i to be deleted from a list?
remove()
Correct!
What allows a value to be added at the end of a list?
append()
Correct!
What allows a value to be inserted into a list at index i?
index()
Correct!
100.00%
Your total score is:  4 out of 4. Not too bad, keep on studying! 
nums = ["1", "2", "3", "4", "5", "6"]

num_min = nums[0]
for num in nums:
    if num_min > num:
        num_min = num
print("min= " + num_min)
min= 1

Reference sheet notes:

  1. alist[i] <-- x

    this assigns list index to the var x

  2. alist[i] <-- blist[x]

    this assigns list index i to blist index x

  3. remove(alist, i)

    this removes the item i of alist. len(alist) decreases by 1

  4. insert(alist, i, value)

    opposite of remove