In python what character precedes every indent (excepting level 0)?
: colon
What character in python is used to indicate that the line is a comment and not code to be evaluated and executed?
#
What does API stand for?
Application Programming Interface
What can happen when the condition on a while loop is always True?
infinite loop
Which tag is the root element of an HTML page?
<html>
How many lines of code are encapsulated by the second loop?
def drawHouses(num):
for i in range(num):
turtle.down()
for i in range(4):
turtle.forward(50)
turtle.right(90)
turtle.right(180)
2
Which import statement is required to make the following line of code work?
print(random.choice(texts))
import random
Which of the following statements does NOT evaluate to True or False?
a = b a == b a != b
a = b
Which loop in python is a condition controlled loop? (while, for, repeat, repeat until)
while
Which character is used to indicate an end tag?
/
What will be printed when this code is executed?
def mystery(num):
for i in range(num):
print("Hello World")
print("done")
mystery(2)
Hello World
Hello World
done
In python, how do you create a variable called animal and set it equal to the string "dog".
animal = "dog"
What is the correct way to call the mystery function and print the return value?
def mystery(stuff):
newstuff = ""
for i in range(len(stuff)-1,-1,-1):
newstuff += stuff[I]
return newstuff
print(mystery("I love a good mystery"))
What will this code print?
x=0
while x < 5
print(x)
x = x+1
print ("done")
0
1
2
3
4
done
Who is making the Web standards?
The World Wide Web Consortium
Binary
What line of code will get data from the user and put it in a variable called sound?
sound = input("Enter a sound: ")
What will the following code print?
def first():
print("I am first")
return
print(first())
I am first
None
Assume there are two valid conditions 'j' and 'k' and they are stored in the variable 'quest'. What would the while loop be?
while not (quest=="j" or quest=="k"):
What HTML tag does not have an end tag?
<br>
What does the following code draw:
turtle.goto(0,-80)
turtle.clear()
turtle.pensize(10)
turtle.color("yellow")
turtle.goto(50,80)
turtle.goto(-80,-20)
turtle.goto(80,-20)
turtle.goto(-50,80)
turtle.goto(0,-80)
Star
What are two of the three rules for python identifiers (variable names, function names, etc)
1. Can't be python keywords
2. Can't contain spaces
3. Can't begin with a number
Decrypt this Caesar Cipher:
xeehqo oek wej vylu xkdthut feydji
Key: 10 to the right
Message: hooray you got five hundred points
What is still wrong with this debug it (the midterm template)?
def choice3():
ans = input("The third choice: (up or down) ")
while not (ans == 'up' or ans == 'down'):
ans = input("Invalid Input: Choose (up or down)? ")
if ans == "up":
print("up is a bad choice, game ended")
else:
print("down is the correct choice, game ended")
The indentation is not correct, so if you enter "up" or "down" the first time you won't see the answer.
def choice3():
ans = input("The third choice: (up or down) ")
while not (ans == 'up' or ans == 'down'):
ans = input("Invalid Input: Choose (up or down)? ")
if ans == "up":
print("up is a bad choice, game ended")
else:
print("down is the correct choice, game ended")
What is the difference between latency and bandwidth?
Latency measures how much time it takes to get from one place to another. Bandwidth measures capacity (how much traffic can use the route).