Font size
WorksheetsFund of CS Fall Review 1
Total questions: 75
Worksheet time: 37mins
A while loop can be used in which of the following situations?
Repeat a set of statements till a condition remains True.
Repeat a set of statements a finite or an infinite number of times.
Iterate through a string, list, and tuple.
All of the above
Kind of loop used when you know the number of times you want it to repeat
list
for
while
if
Which variable correctly stores a string value?
greeting = hello
greeting = 81
greeting = "hello"
greeting = 45.8
__________ are used to make logical associations between boolean values.
Operands
Operators
logical operators
mathematical operators
Loop that runs till the condition is true
list
while
for
if
Kind of loop used when you know the number of times you want it to repeat
list
for
while
if
What is an iteration?
A single loop
Repeated execution of a list of statements.
Repeated execution of loops
Repeated execution of variables
Terminates the loop statement and transfers execution to the statement immediately following the loop
pass statement
continue statement
break statement
break will break out of an iteration
true
false
continue will move to the next iteration
true
false
A range will go to the last number listed but not include it
true
false
If there is a circumstance where you do not want to break out of a loop, but just skip a certain value, you would use
skip
break
continue
Which kind of loop would be used?
I need a revision program that will run through revision questions 4 times.
FOR Loop
WHILE Loop
This loop condition never becomes FALSE.
while loop
for loop
nested loop
infinite loop
Which one of the statements below will cause an error?
ans = “hi” * 8
ans = “hi” + 9
ans = “hi” + “hi” + “hi”
ans = (“a” * 4) + “b”
Which of the following statements is true about print statements?
I. In order to print a string literal, the string must be enclosed in quotes.
II. Each print statement will be printed on its own line.
III. Print statements will not let you print string and number characters in the same statement.
IV. Print statements are how you display text on the screen.
I, IV
II, III
I, II, IV
I, III, IV
Suppose you have a variable defined a = "4". What is the variable type of a?
str
int
float
number
Which of the following choices is NOT a Python variable type?
int
str
float
number
In what order should these statements be executed in order to get input from the user and print out the result?
A) response = input("Do you like cheese? ")
B) print("You have chosen " + confirm)
C) print("You responded " + response)
D) confirm = input("Are you sure? ")
A, B, C, D
B, C, A, D
A, C, D, B
C, B, A, D
What is the output?
more than 7
more than 23
spam
7
Pieces of code that only run "under certain conditions":
conditional statements
control flow statments
syntax
variables
Which symbol means "not equal to"?
==
<=
>=
!=
Which character must be at the end of the line for if?
:
;
.
{
What does the = = symbol mean in Python?
Equal to or shows equality
Not Equal
Code that will be skipped
End of clause
What will be displayed at the end of the program?
Case 1
Case 2
Nothing will be displayed.
Case 1 and Case 2
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print i
for i in range(3, 9, 2):
print i
for i in range(9):
print i
for i in range(3,9):
print i
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
What is the output?
next
stop
next
stop
syntax error - program doesn't work
How many "if" statements can a single program have?
<10
<20
<30
As many as is needed
What is a flowchart used for in programming? click all of the correct answers
planning
building
testing
debugging
What is the name of the function?
When defining a function, the definition must occur before it is called.
true
false
How do you identify the statements that belong to the body of a function?
Indent those statement the same amount underneath the function "def" statement
Add opening and closing curly braces { and } to mark the start and stop of the function body
Add the "def" keyword to the beginning of each statement
Add the same comment (#) to the right of each statement within the body
Are there any syntax errors?
No
Quotations are not needed on line 1
Elif does not exist
There should be a colon on line 7
What is the correct name for this symbol?
==
Assignment
Equal to
Greater than
Less than
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
Which is correct?
A
B
Improper tab placement will prevent a block of code from running properly.
True
False
The letter 'FALSE' is which data type that has 2 possible answers?
String
Real/Decimal/Float
Integer
Boolean
Char
The 3.45 is which data type?
String
Real/Decimal/Float
Integer
Boolean
Char
The word 'Tuesday' is which data type?
String
Real/Decimal/Float
Integer
Boolean
Char
What will this piece of code do when it runs for John Smith born in June and the day of his birthday is Tuesday?
print("Hello " + name + "Your birthday month is " + month +
" and the day of your birthday this year is " + day)
"Hello " + name + "Your birthday month is " + month +
" and the day of your birthday this year is " + day
Hello John Smith Your birthday month is June and the day of your birthday this year is Tuesday
Hello John Smith Your birthday month is June and the day of your birthday this year is Monday
"Hello "John Smith "Your birthday month is " + month +
" and the day of your birthday this year is " + day
When you run this program what will this line of code do?
name = input("Enter your name: ")
Ask you to Enter your name and save your answer to Google Drive
Ask you to Enter your name and save your answer to My Documents
Ask you to Enter your name
Ask you to Enter your name and save your answer as a variable
What is the syntax error with this code:
print”Hello World”
No brackets around "Hello World"
Speech marks are not needed
Colon is not needed
print is spelt incorrectly
Print has a capital P
Which value is a String ?
64
0.5
"cat"
True
Which value is a integer?
64
0.5
"cat"
True
What will the following code do?
prints bob
prints Hello Bob
nothing syntax error
prints I don't know you
Which construct would you use to make your program branch?
if...else
while
for
def
What does the % operator do?
Calculates the modulus (remainder) of two numbers
Calculates the quotient of two numbers
Calculates percentages
Nothing at all
age = '5'
In the code above, age is a
string
integer
floating point
What is the correct extension for python files ?
.py
.pyth
.python
How to insert comments in Python ?
# this is a comment
// this is a comment
/* this is a comment */
Which operator checks if a value is not equal to another value?
==
+=
!=
=
Which operator performs a multiplication?
+
/
X
*
An Opearand is:
The value of the operation
The value that the total operation is equal to
The value on the left or right of an operator. The values on which the operation will be performed.
The value in the print statement
An Operator is:
A person that performs operations
a symbol that specifies the operation to perform
a symbol that means the code will run
a line of code
Choose the correct output of the following code.
for i in range(10,15):
print(i)
10
11
12
13
14
15
10
11
12
13
14
11
12
13
14
15
11
12
13
14
The equivalent of the above for loop using the while syntax would be
for i in 100 :
print ( i )
Syntax error
prints numbers 0 to 100
prints numbers 1 to 100
prints numbers 0 to 99
prints numbers 1 to 99
A while loop equivalent of the for loop above is
1,2,3,4
When do you know when you come to the end of the loop?
Its states End loop
The command End is given
The indentation stops
Repeats statements or a group of statements while a given condition is true
while loop
for loop
nested loop
Terminates the loop statement and transfers execution to the statement immediately following the loop
pass statement
continue statement
break statement
Which kind of loop would be used?
I need a program that will keep letting me add a monthly payment for 12 months.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a revision program that will run through revision questions 4 times.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a guessing game program that will let me keep guessing until I get the right answer.
FOR Loop
WHILE Loop
You can use one or more loop inside any another while, for or do..while loop.
while loop
for loop
nested loop
infinite loop
This loop condition never becomes FALSE.
while loop
for loop
nested loop
infinite loop
