wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Fund of CS Fall Review 1

Total questions: 75

Worksheet time: 37mins

Name
Class
Date
1.

A while loop can be used in which of the following situations?

a)

Repeat a set of statements till a condition remains True.

b)

Repeat a set of statements a finite or an infinite number of times.

c)

Iterate through a string, list, and tuple.

d)

All of the above

2.

Kind of loop used when you know the number of times you want it to repeat

a)

list

b)

for

c)

while

d)

if

3.

Which variable correctly stores a string value?

a)

greeting = hello

b)

greeting = 81

c)

greeting = "hello"

d)

greeting = 45.8

4.

__________ are used to make logical associations between boolean values.

a)

Operands

b)

Operators

c)

logical operators

d)

mathematical operators

5.

Loop that runs till the condition is true

a)

list

b)

while

c)

for

d)

if

6.

Kind of loop used when you know the number of times you want it to repeat

a)

list

b)

for

c)

while

d)

if

7.

What is an iteration?

a)

A single loop

b)

Repeated execution of a list of statements.

c)

Repeated execution of loops

d)

Repeated execution of variables

8.

Terminates the loop statement and transfers execution to the statement immediately following the loop

a)

pass statement

b)

continue statement

c)

break statement

9.

break will break out of an iteration

a)

true

b)

false

10.

continue will move to the next iteration

a)

true

b)

false

11.

A range will go to the last number listed but not include it

a)

true

b)

false

12.

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

a)

skip

b)

break

c)

continue

13.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

14.

This loop condition never becomes FALSE.

a)

while loop

b)

for loop

c)

nested loop

d)

infinite loop

15.

Which one of the statements below will cause an error?

a)

ans = “hi” * 8

b)

ans = “hi” + 9

c)

ans = “hi” + “hi” + “hi”

d)

ans = (“a” * 4) + “b”

16.

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.

a)

I, IV

b)

II, III

c)

I, II, IV

d)

I, III, IV

17.

Suppose you have a variable defined a = "4". What is the variable type of a?

a)

str

b)

int

c)

float

d)

number

18.

Which of the following choices is NOT a Python variable type?

a)

int

b)

str

c)

float

d)

number

19.

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)

A, B, C, D

b)

B, C, A, D

c)

A, C, D, B

d)

C, B, A, D

20.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
21.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
22.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

23.

Pieces of code that only run "under certain conditions":

a)

conditional statements

b)

control flow statments

c)

syntax

d)

variables

24.

Which symbol means "not equal to"?

a)

==

b)

<=

c)

>=

d)

!=

25.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

26.

What does the = = symbol mean in Python?

a)

Equal to or shows equality

b)

Not Equal

c)

Code that will be skipped

d)

End of clause

27.

What will be displayed at the end of the program?

a)

Case 1

b)

Case 2

c)

Nothing will be displayed.

d)

Case 1 and Case 2

28.

Which of the following for loops would print the following numbers?

3

5

7

9

a)

for i in range(3, 10, 2):

print i

b)

for i in range(3, 9, 2):

print i

c)

for i in range(9):

print i

d)

for i in range(3,9):

print i

29.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

30.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

31.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

32.

How many "if" statements can a single program have?

a)

<10

b)

<20

c)

<30

d)

As many as is needed

33.

What is a flowchart used for in programming? click all of the correct answers

a)

planning

b)

building

c)

testing

d)

debugging

34.

What is the name of the function?

4 lines
35.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

36.

How do you identify the statements that belong to the body of a function?

a)

Indent those statement the same amount underneath the function "def" statement

b)

Add opening and closing curly braces { and } to mark the start and stop of the function body

c)

Add the "def" keyword to the beginning of each statement

d)

Add the same comment (#) to the right of each statement within the body

37.

Are there any syntax errors?

a)

No

b)

Quotations are not needed on line 1

c)

Elif does not exist

d)

There should be a colon on line 7

38.

What is the correct name for this symbol?


==

a)

Assignment

b)

Equal to

c)

Greater than

d)

Less than

39.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

40.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
41.

Which is correct?

a)

A

b)

B

42.

Improper tab placement will prevent a block of code from running properly.

a)

True

b)

False

43.

The letter 'FALSE' is which data type that has 2 possible answers?

a)

String

b)

Real/Decimal/Float

c)

Integer

d)

Boolean

e)

Char

44.

The 3.45 is which data type?

a)

String

b)

Real/Decimal/Float

c)

Integer

d)

Boolean

e)

Char

45.

The word 'Tuesday' is which data type?

a)

String

b)

Real/Decimal/Float

c)

Integer

d)

Boolean

e)

Char

46.

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)

a)

"Hello " + name + "Your birthday month is " + month +

" and the day of your birthday this year is " + day

b)

Hello John Smith Your birthday month is June and the day of your birthday this year is Tuesday

c)

Hello John Smith Your birthday month is June and the day of your birthday this year is Monday

d)

"Hello "John Smith "Your birthday month is " + month +

" and the day of your birthday this year is " + day

47.

When you run this program what will this line of code do?

name = input("Enter your name: ")

a)

Ask you to Enter your name and save your answer to Google Drive

b)

Ask you to Enter your name and save your answer to My Documents

c)

Ask you to Enter your name

d)

Ask you to Enter your name and save your answer as a variable

48.

What is the syntax error with this code:

print”Hello World”

a)

No brackets around "Hello World"

b)

Speech marks are not needed

c)

Colon is not needed

d)

print is spelt incorrectly

e)

Print has a capital P

49.

Which value is a String ?

a)

64

b)

0.5

c)

"cat"

d)

True

50.

Which value is a integer?

a)

64

b)

0.5

c)

"cat"

d)

True

51.

What will the following code do? 

a)

prints bob

b)

prints Hello Bob

c)

nothing syntax error

d)

prints I don't know you

52.
What does INT means in python?
a)
Decimal Numbers
b)
Whole Number
c)
Text
d)
Floating Point Number
53.
Why are the indents necessary after the if and else statements?
a)
Do not follow these instructions above 
b)
Logic of the code will make sense
c)
Follow these instructions if the statement above is true
d)
Code will have no syntax error
54.

Which construct would you use to make your program branch?

a)

if...else

b)

while

c)

for

d)

def

55.

What does the % operator do?

a)

Calculates the modulus (remainder) of two numbers

b)

Calculates the quotient of two numbers

c)

Calculates percentages

d)

Nothing at all

56.

age = '5'


In the code above, age is a

a)

string

b)

integer

c)

floating point

57.

What is the correct extension for python files ?

a)

.py

b)

.pyth

c)

.python

58.

How to insert comments in Python ?

a)

# this is a comment

b)

// this is a comment

c)

/* this is a comment */

59.

Which operator checks if a value is not equal to another value?

a)

==

b)

+=

c)

!=

d)

=

60.

Which operator performs a multiplication?

a)

+

b)

/

c)

X

d)

*

61.

An Opearand is:

a)

The value of the operation

b)

The value that the total operation is equal to

c)

The value on the left or right of an operator. The values on which the operation will be performed.

d)

The value in the print statement

62.

An Operator is:

a)

A person that performs operations

b)

a symbol that specifies the operation to perform

c)

a symbol that means the code will run

d)

a line of code

63.

Choose the correct output of the following code.

for i in range(10,15):       

print(i)

a)

10

11

12

13

14

15

b)

10

11

12

13

14

c)

11

12

13

14

15

d)

11

12

13

14

64.

The equivalent of the above for loop using the while syntax would be

a)
b)
c)
d)
65.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

66.

A while loop equivalent of the for loop above is

a)
b)
c)
d)
67.
a)
b)
c)
d)

1,2,3,4

68.

When do you know when you come to the end of the loop?

a)

Its states End loop

b)

The command End is given

c)

The indentation stops

69.

Repeats statements or a group of statements while a given condition is true

a)

while loop

b)

for loop

c)

nested loop

70.

Terminates the loop statement and transfers execution to the statement immediately following the loop

a)

pass statement

b)

continue statement

c)

break statement

71.

Which kind of loop would be used?


I need a program that will keep letting me add a monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

72.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

73.

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.

a)

FOR Loop

b)

WHILE Loop

74.

You can use one or more loop inside any another while, for or do..while loop.

a)

while loop

b)

for loop

c)

nested loop

d)

infinite loop

75.

This loop condition never becomes FALSE.

a)

while loop

b)

for loop

c)

nested loop

d)

infinite loop