My CSP Journey
Hi my name is Max. This is my page to document my journey through CSP. My computer science journey truly started in 8th grade. There were many electives to choose going into the 8th grade, I ended up choosing computer science because that was the class that all of my friends were planning on taking. Having no previous experience in computer science, I naturally struggled throughout the year. But with pain often comes joy. I remember creating my first website using html, spending hours trying to improve every little detail to make my website more appealing. Submitting the website was one of the happiest moments of my life. That feeling of accomplishment is what motivated me to enroll in this class. Having never touched a line of code in three years, it is not surprising to say that I am really rusty.
The first thing I learned in Mr. Mortensen's CSP class is iterations or loops. Iteration is a sequence of instructions that is continually repeated. With iteration, I made a cool little quiz.
def q_and_a(prompt):
print("Question: " + prompt)
msg = input()
return msg
questions = 6
correct = 0
print("Hello, you will be taking the vocabulary test.")
print("Do you wish to proceed?(y/n)")
msg = input()
while (msg!="y") :
print("ERROR, YOU HAVE TO SAY YES, DON'T HAVE A CHOICE")
msg = input()
print("You may now proceed")
rsp = q_and_a("Does static text change? (yes/no)")
if rsp == "no":
print(rsp +" is correct")
correct += 1
else:
print(rsp +" is wrong :(")
rsp = q_and_a("At least how many lines are required to form a sequence of code?(1-4)")
if rsp == "2":
print(rsp + " is correct!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = q_and_a("Is Input and Output in jupyter notebooks in line with Output?(yes/no)")
if rsp == "no":
print(rsp + " is correct!!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = q_and_a("Is the computer mice an input?(yes/no)")
if rsp == "yes":
print(rsp + " is correct!!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = q_and_a("What is a number with a decimal in it called?")
if rsp == "float":
print(rsp + " is correct!!")
correct += 1
else:
print(rsp + " is incorrect!")
rsp = q_and_a("What is a set of instructions that a computer follows in order to complete a task called?")
if rsp == "program":
print(rsp + " is correct!!")
correct += 1
else:
print(rsp + " is incorrect!")
print(" you scored " + str(correct) +"/" + str(questions))
We haven't learned this yet, but I wanted to challenge myself with a mini project so I decided to write some algorithms for the different sorting methods.
def bubble_sort(list):
index_length = len(list)
swapped = False #create variable of swapped and set it to false
for i in range(index_length-1): #number of iterations
for j in range(0, index_length-1): #for every value between the first value and second to last value
if list[j] > list[j+1]:
swapped = True #values are swapped
list[j], list[j+1] = list[j+1], list[j] #switch positions
return list
list = [64, 34, 25, 12, 22, 11, 90]
bubble_sort(list)
print(list)
def selection_sort(list):
indexing_length = len(list)
for i in range(indexing_length - 1): #the number of iterations
minpos = i #whatever before i is sorted, whatever after i is unsorted; i is the min position
for j in range(i, indexing_length): #for every value between i and the last value
if list[j] < list[minpos]:
minpos = j #set j as the new minpos if j is less than i
list[minpos], list[i] = list[i], list[minpos] #switch positions
return list
list = [64, 34, 25, 12, 22, 11, 90]
selection_sort(list)
print(list)