1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is displayed by the following code?
for i in range(3):
print ("Go ")
for j in range(3):
print ("Huskies! ")
Go
Huskies!
Huskies!
Huskies!
Go
Huskies!
Huskies!
Huskies!
Go
Huskies!
Huskies!
Huskies!
What is displayed by the following code?
for i in range(3):
print ("Go ")
for j in range(i + 1):
print ("Huskies! ")
Go
Huskies!
Go
Huskies!
Huskies!
Go
Huskies!
Huskies!
Huskies!
Which of the following are true?
1.You can nest if statements within loops
2.You can nest loops within if statements
3.You cannot nest loops within other loops
1 and 2
What is displayed by the following code?
word = "milkshake"
print (word[3])
k
Which of the following for loops designs will repeat 10 times?
1.for x in range(10):
2.for y in range(1, 10):
3.for z in range(1, 11):
1 and 3
Given the following code, what is stored in q?
def mangle(x, y):
if x > y:
z = 8
else:
z = 6
return z
def tangle (c):
b = 0
j = 1
while j < c:
b += j
j *= 2
return b
q = tangle(mangle(30, 60))
7
Look up the random object (Links to an external site.) in the Python online documentation
Which of the following functions of the random object returns a random floating point number in the range of 0.0 up to 1.0 (but not including 1.0)?
Random
What is the term for a special value that indicates that a repetitive process should stop?
exit sentinel
How many times will Hello be displayed in the code below?
def showStuff():
for j in range(3):
print ("Hello")
for i in range(4):
showStuff()
12 (with margin: 0)
How many times will "Hello" be displayed in the program below?
def showStuff( k ):
for i in range(k):
print ("Hello")
for j in range(3):
showStuff( j )
3 (with margin: 0)
A loop cannot contain a selection structure in its body.
False
A loop can be placed in any branch of a selection structure.
True
What will be displayed by the program code below?
a = 4
b = 2
if a > 3 and a < 7:
if( b != 2 ):
print (a + b)
else:
print (a - b)
else:
print (b - a)
2 (with margin: 0)
What string is stored in the variable result after this code executes? Remember to write your answer using quotes.
result = '' # starts as the empty stringfor ch in 'shoes':
result = ch + result
"seohs"
Which method returns true if a string contains only alphabetical letters?
isalpha()