Should I take CS 110 or skip to CS 111? 🤔
Take this quiz with no external help, bots, or searches to see if you are ready for CS 111 or should consider taking CS 110 first.
Please NoteYour results are just for you and are not recorded in any way.
Question 1
What does this code print?
x = 1
y = 7
for i in range(3):
x += 1
print(x)
Python syntax notes:
- The statement
for i in range(n)is functionally equivalent to the C++ or Java statementfor (i=0; i<3; i++) - The
+=operator combines assignment with addition. Hence,x += 1is equivalent tox = x + 1
Question 2
What does the following code print?
password = "password"
result = ""
capitalize = True
for character in password:
if capitalize:
result = result + character.upper()
capitalize = False
else:
result = result + character
capitalize = True
print(result)
Python syntax notes:
for character in password:will set the character variable to each letter inpasswordone at a time.string.upper()will convert the entire string to upper-case letters.+operator is used to concatenate strings or characters. For example,a = "tes" + "t"will assign the variableato the value"test".- The body of an if statement or else does not require
{}. Instead, a set of grouped statements is indicated by a sequence of lines sharing the same amount of indentation.
Question 3
What will this code print?
def add_question(words):
new_words = []
for word in words:
if 'q' in word:
word += '?'
new_words.append(word)
return new_words
def add_exclamation(words):
new_words = []
for word in words:
if '?' in word:
word += '!'
new_words.append(word)
return new_words
words = ["Quick!", "The", "queen", "asked", "a", "question!"]
words = add_question(words)
words = add_exclamation(words)
print(words[2])
Python syntax notes:
[]denotes an empty list, which is like an empty array or an empty vector..append()operation adds a new item to the end of the list, increasing the list's length by one.for word in wordswill iterate through each element in the list, assigning the value of that element to word.+operator can be used to concatenate strings.
Question 4
In the following code, which function is defined?
from operator import add
def sumThreeNumbers(a, b, c):
return a + b + c
a = 5
b = 3
c = 1
answer = add(a, b) + add(b, c)
Question 5
In the following code, which function is called?
from operator import add
def sumThreeNumbers(a, b, c):
return a + b + c
def mulThreeNumbers(a, b, c):
return a * b * c
a = 5
b = 3
c = 1
answer = sumThreeNumbers(a, b, c)
Question 6
What will the following code print?
def multiplyThreeNumbers(a, b, c):
return a + b + c
a = 5
b = 3
c = 1
d = ((a - b) * b) / c
answer = multiplyThreeNumbers(d, d, d)
print(answer)
Question 7
In the code below, which item is a variable?
my_function = 5
pow(5, 3)
print("test")
Question 8
What will the following code print?
n = 0
while n < 7:
if n < 2:
n = n + 1
elif n < 5:
n = n + 2
else:
n = n + 3
print(n)
Language note: In Python, elif means else if.
Question 9
Using a programming language and development environment of your choice, write a program that:
- Requests that the user enter a string and stores the user's response in a variable.
- Reverses the order of the string; for example, the string "Catastrophe!" should become "!ehportsataC".
- Creates and displays for the user a new string that includes only every second letter from the reversed string. For example, if the user entered "Catastrophe!" the final output should be "!hotaa".
Allow yourself up to 15 minutes for this question. Do not use any outside resources beyond your brain, your development environment, and this quiz. At the end of 15 minutes, or when you are done, select the checkbox that best describes your experience.
Question 10
Using a programming language and development environment of your choice, write a program that:
- Defines a function named MyCoolFunction that accepts two parameters named x and y. When called, MyCoolFunction should return the value $2*x + y - 1$.
- Defines two variables named A and B, then calls MyCoolFunction on A and B and stores the result in a new variable named C.
- Returns the result of calling MyCoolFunction on A and C. When A=5 and B=0, the result of running your program should be 18.
Allow yourself up to 15 minutes for this question. Do not use any outside resources beyond your brain, your development environment, and this quiz. At the end of 15 minutes, or when you are done, select the checkbox that best describes your experience.
Question 11
Using a programming language and development environment of your choice, write a program that will calculate the area of an arbitrary shape (circle, triangle, square, or rectangle) given the necessary radius or side length(s). You may choose whether the shape type and radius/side length(s) are hard-coded as a variable at the top of your code, or whether the system will prompt the user for the needed values one at a time.
If the shape to be calculated is a circle, the calculated area should be $A=\pi*r^2$. For a triangle, $A=\frac 1 2 * l * h$. For a square, $A=l*l$. For a rectangle, $A=w*h$.
Allow yourself up to 30 minutes for this question. Do not use any outside resources beyond your brain, your development environment, and this quiz. At the end of 30 minutes, or when you are done, select the checkbox that best describes your experience.
Show score!
A score of 10 or above suggests that you are very well prepared for CS 111.
A score between 8 and 9 suggests that you can do well in CS 111 with some additional effort beyond that required of most students.
A score below 8 suggests that you will have a difficult time in CS 111, and should consider switching to CS 110.