Exercise 1

list = [1, 2, 3, 4, 5] # Print this list in reverse orde
print("Original List")
print(list)
print("Reversed List")
list.reverse()
print(list)
Original List
[1, 2, 3, 4, 5]
Reversed List
[5, 4, 3, 2, 1]

Exercise 2

list = [9, 8, 4, 3, 5, 2, 6, 7, 1, 0]
print(f"Original {list}")
def insertion_sort(list):
    for index in range(1,len(list)):
        value = list[index]
        i = index - 1
        while i >= 0:
            if value < list[i]:
                list[i+1] = list[i]
                list[i] = value
                i = i - 1
            else:
                break

sl = insertion_sort(list)
print(f"Sorted {list}")
Original [9, 8, 4, 3, 5, 2, 6, 7, 1, 0]
Sorted [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Lessons

As I went through these problems, I learned a lot more about making functions and the thought process behind them. Coming into coding with no knowledge makes everything look a lot scarier. Seeing the steps and hearing the explanation behind them helps a lot. Exercise 2 especially was challenging. I used a heavy inspiration from the class notes and managed to figure it out.

Multiple Choice Quiz

Queston 1

Queston 2

Queston 3

Queston 4

Queston 5

Queston 6

Queston 7

Questions 1-7 Reflection

These first few questions were pretty basic and easy to answer. Most of them were matching the command to the definition.

Queston 8

Queston 9

Queston 10

Questions 8-10 Reflections

These next three questions were a lot harder for me. I understand a lot of the basic definitive concepts, but I still struggle on more of the harder concepts.

Question 8

While loop = a loop that repeats WHILE the condition is met

Question 9

Honestly this was a straight forward question, for loops run until the condition is met

Question 10

I have no idea how to answer this question, I will ask in class. If I had to guess one for loop to go through each list, and then another for loop nested in it that goes through the list until the end.