wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

G8 2nd Test Review

Total questions: 100

Worksheet time: 1hrs 16mins

Name
Class
Date
1.

The command that will print a line of command on the program is:

a)

echo

b)

print

c)

hey, Alexa

d)

speak

2.

Which of the following is a Python command

a)

@echo off

b)

print ("")

c)

print "name"

d)

echo.

3.

In Python, a variable needs to

a)

start with a letter or underscore

b)

be stated before "print"

c)

have % symbols on either side

d)

Variable????? We don't need variables!!!!

4.

Data that is collected and sent to a computer is

a)

input

b)

output

c)

storage

d)

process

5.

Presenting the results back to a user is known as

a)

input

b)

output

c)

storage

d)

processing

6.

Carrying out instructions is known as

a)

input

b)

output

c)

processing

d)

storage

7.

print (name + " is " + age " years old") This is an example of:

a)

input

b)

output

c)

processing

d)

storage

8.

Mr. Whiting is 45 years old. This is an example of:

a)

input

b)

output

c)

processing

d)

storage

9.

In Python, to have text stated for the user to see, we use:

a)

" "

b)

% %

c)

( )

d)

? ?

10.

In Python, to make remarks that the computer will ignore, we use:

a)

rem

b)

#

c)

IGNORE!

d)

( )

11.

The Boolean operator that means "not equal to" is

a)

XX

b)

!=

c)

<>

d)

_

12.

Which is correct?

a)

if num1=10:

b)

if num1==10:

c)

if num1==10;

d)

if num="10";

13.

When writing an if/else statement, you

a)

always indent the line after the condition

b)

never indent the line after the condition

c)

capitalize every word

d)

put a colon at the beginning and the end

14.

Which is correct?

a)

if num1==42:

print("You have discovered the meaning of life!")

b)

if num1==42...

print("You have discovered the meaning of life!")

c)

if num1==42:

print "You have discovered the meaning of life!"

d)

if num1==42:

print( You have discovered the meaning of life!)

15.

In Python, the command "while" will create a:

a)

loop

b)

variable

c)

function

d)

a chocolate cake

16.

In Python, iteration is another word for a:

a)

loop

b)

variable

c)

function

d)

command

17.

In a loop, as long as the user enters an answer that is "true,"

a)

the command repeats itself

b)

the program ends

c)

the programs starts over

d)

the user gains 10 points

18.

How do you declare a variable in python?

a)

score = 100

b)

int score = 100;

c)

def score(100):

d)

score 100

19.

What are TWO ways I can add 100 to the variable "score"?

a)

score += 100

b)

score = score + 100

c)

score + 100

d)

score = 100

20.

Which symbol represents modulo, which means to divide two numbers and keep the remainder?

a)

%

b)

**

c)

//

d)

/

21.

Which is the correct way to use the floor division operator, which divides two numbers and throws out the remainder?

a)

score = score//10

b)

score = score/10

c)

score//10

d)

score = score** 10

22.

Which operator raises one number to the power of another?

a)

**

b)

*

c)

^

d)

&

23.

What's wrong with this if statement?

a)

it should have a "==" operator

b)

line two shouldn't be tabbed over

c)

it needs parenthesis ( ) around the condition

d)

it shouldn't have a colon (:) at the end of line 1

24.

What will this print?

a)

you lose

b)

you win

c)

nothing

d)

error message

25.

What will this code print?

a)

you lose

b)

you win

c)

nice try

d)

nothing

26.

What will this code print?

a)

you lose

b)

you win

c)

nice try

d)

nothing

27.

What will this code print?

a)

1 through 10

b)

1 through 9

c)

0 through 10

d)

0 through 9

28.

What will this code print?

a)

2 through 20, counting by 2s

b)

2 through 22, counting by 2s

c)

4 through 20, counting by 2s

d)

4 through 22, counting by 2s

29.

What will this code print?

a)

5,4,3,2,1

b)

4,3,2,1

c)

5,4,3,2,1,0

d)

nothing

30.

What will this code print?

a)

2,4,6,8

b)

2,4,6

c)

4,6

d)

2,3,4,5,6,7,8

31.

What will this code print?

a)

'a', and then any letter the user types until they press 'q'

b)

Any letter the user types until they press 'q'

c)

nothing

d)

'a' until the user types 'q'

32.

What will this code print?

a)

nothing

b)

'b', and then any letter the user types until they press 'q'

c)

'b' until the user types 'q'

d)

any letter the user types until they press 'q'

33.

What's wrong with this code?

a)

nothing, it works fine

b)

it's missing arguements in the parenthesis ( )

c)

it's missing a return value

d)

line 3 should be tabbed over

34.

What is a input?

a)

To plug in something.

b)

A function that allows us to ask the user to enter some data.

c)

Data displayed on a screen.

d)

A function

35.

What in the name of the variable in this Python code?

a)

name

b)

input

c)

print

d)

("What is your name")

36.

Which of these is not an arithmetic operator?

a)

+

b)

-

c)

*

d)

=

37.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
38.

What is the output of the following code snippet?

   x = 5

   if x > 3:

       print("Greater than 3")

   else:

       print("Less than or equal to 3")

  

a)

Greater than 3

b)

Less than or equal to 3

c)

Invalid syntax

d)

No output

39.

What is the output of this code?

a)

X

b)

Y

c)

Error

40.

print(“What year is it?”)

year = int(input())

What datatype is the variable year?

a)

integer

b)

float

c)

string

41.

print(“Enter a price.”)

money = float(input())

What datatype is the variable money?

a)

integer

b)

float

c)

string

42.

print(“Please enter your age.”)

age = int(input())

What datatype is the variable age?

a)

integer

b)

float

c)

string

43.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
44.
Which of the following will print:
a)
for i in range(1, 5):   
print(str(i) * 5)
b)
for i in range(1, 5):   
print("i" * i)
c)
for i in range(1, 6):   
print("i" * i)
d)
for i in range(1, 6):   
print(str(i) * i)
45.

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)

46.

What would be the output of the following code:

for i in range(3):

print(5)

a)

0 1 2

b)

3 3 3 3 3

c)

5 5 5

d)

0 1 2 3 4

47.
This operator means that one value is not equal to another value
a)
==
b)
<=
c)
>=
d)
!=
48.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

49.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

50.

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

51.

If the user inputs : 2 , what does the following code snippet print ?

a)

Yes

b)

No

c)

May be

d)

Nothing printed

e)

Error

52.

There can be an else statement without an if statement

a)

FALSE

b)

TRUE

53.

It is possible to execute both the statements under if and else at the same time.

a)

TRUE

b)

FALSE

54.

When this code is run, it prints "Ok, sure." every time, no matter what number the user enters. Why?

a)

its the last line of code

b)

x is an int and the conditions checked are equality to strings

c)

The else will always override the elif

d)

You can't have both an if and an elif

55.

How many elif's can you have chained together in an if statement?

a)

as many as you want

b)

only 1, followed by an else

c)

up to and including 3

d)

only 2 followed by an else

56.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

1

57.

Why the code is incorrect?

a)

Because is missing the indentation in the second line

b)

The keyword "print" should be in capital letter

c)

The two points are unnecessary

58.

What is a variable?

a)

Are expressions that evaluate to either true or false. They are mostly used to determine Program Flow through if statements and while loops.

b)


Is a data item whose value cannot change during the program's execution.

c)

Are used to store information to be referenced and manipulated in a computer program.

59.

In the following code:

X=float("Enter a number")

x=float("Enter a number")

print(x)

What is the number of variables?

a)

One

b)

Two

c)

Three

60.

What is the output of the following code?

x = 7
if x % 2 == 0:
    print("Even")
else:
    print("Odd")

a)

Even

b)

Odd

c)

7

d)

Error

61.

What is the output of the following code?

y = 8
if y % 2 == 0:
    print("Even")
else:
    print("Odd")

a)

Even

b)

Odd

c)

8

d)

Error

62.

What is the output of the following code?

z = 12
if z > 10:
    print("z is greater than 10")
else:
    print("z is less than or equal to 10")

a)

z is greater than 10

b)

z is less than or equal to 10

c)

z is equal to 10

d)

Error

63.

What's the main advantage of using a for-loop, rather than manually repeating the code?

a)
For-loops can only be used with numeric data types.
b)

It reduces the chance of making errors by keeping the code concise..

c)
For-loops are slower than manual code execution.
d)
For-loops require more memory than repeating code.
64.

What is the output of the following code?

for i in range(3, 4):

print(i)

a)
3.5
b)
3
c)
2
d)
4
65.

What is the main purpose of a while loop in Python?

a)
To execute a block of code only once regardless of the condition.
b)
To define a function that can be called multiple times.
c)

To execute a block of code while a certain condition is true.

d)
To create a static loop that does not change based on conditions.
66.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

67.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

68.
a)
b)
c)
d)

1,2,3,4

69.

#What is the output?

a)

1,2,3,4,5

b)

0,1,2,3,4

c)

1,2,3,4

d)

5,4,3,2,1

70.

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)

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 guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

73.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

74.
What will the following code result in:

name = “Alison”
number = len(name)
print(number)
a)
4
b)
5
c)
6
d)
7
75.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
76.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
77.

A loop that is inside of another loop is known as a what?

a)

Infinite loop

b)

Loop to loop

c)

While Loop

d)

Nested Loop

78.
What will print?
a)
1 2
b)
1
c)
3
d)
5
79.

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

a)
b)
c)
d)
80.

What is the issue with the following code?

a)

If condition will never be fulfil

b)

print cannot be use multiple times

c)

age is always lesser or equals to 18

d)

Printing conflicting statement,, should have an else statement

81.

What is the issue with the following code?

a)

age 18 should already be an adult

b)

no if statement, compile error SyntaxError

c)

missing elif statement

d)

invalid print statement within else condition

82.

FOR loops are

a)

loops which run an unknown number of times

b)

loops that iterates over a sequence in Python

c)

loops which run a known number of times

d)

repeatedly execute a statement as long as the condition provided stays true

83.

WHILE loops are

a)

loops which run an unknown number of times

b)

repeatedly execute a statement as long as the condition provided stays true

c)

loops that iterates over a sequence in Python

d)

loops which run a known number of times

84.
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:
85.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
86.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

87.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

88.
a)
b)
c)
d)

1,2,3,4

89.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
90.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

91.

What will be the output of this code?

a)

2

b)

4

c)

6

d)

12

92.

What will be the output of this code?

a)

2

b)

4

c)

6

d)

12

93.

What will be the output of this code?

a)

1

b)

3

c)

4

d)

5

94.

What is the value of num when this loop completes?


num = 0

for i in range(2, 8, 2):

num += i

a)

2

b)

8

c)

12

d)

20

95.

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

a)

for i in range(0, 5):

b)

for i in range(5):

c)

for i in range(0, 5, 1):

d)

for i in range(5, 0, 1):

96.

What will be the output after the following statements?

a)

true

b)

not false

c)

false

d)

not true

e)

error

97.

What output will be produced by the following segment of code?

a)

Too Low

b)

Too High

c)

Syntax Error

d)

No Output - Logic Error

98.

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

99.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

100.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7