Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Tynker Python Lesson 7-8

Total questions: 84

Worksheet time: 42mins

Name
Class
Date
1.

You need to import the turtle module before you can use the Turtle Tool.

a)

True

b)

False

2.

When you first create a turtle, it starts at (0,0) on the screen. Where will the turtle be if we execute the following code?

turtle.forward(100)

a)

(0,0)

b)

(100,0)

c)

(0,100)

d)

(100,100)

3.

When you first create a turtle, it starts at (0,0) on the screen. Where will the turtle be if we execute the following code?

turtle.right(90)

turtle.forward(100)

a)

(100,0)

b)

(0,-100)

c)

(100,-100)

d)

(100,-100)

4.

When you first create a turtle, it starts at (0,0) on the screen. Where will the turtle be if we execute the following code?

turtle.right(90)

turtle.goto(100,100)

a)

(0,-100)

b)

(0,0)

c)

(100,100)

d)

(200,0)

5.

What function do you use to get the turtle to start drawing?

a)

turtle.penup()

b)

turtle.pendown()

c)

turtle.goto()

d)

turtle.right()

6.

What function do you use to create a new Turtle object?

a)

turtle.Screen()

b)

turtle.Turtle()

c)

turtle.penup()

d)

turtle.goto()

7.

Which of the following code sets the screen's color to red?

a)

screen.color("red")

b)

screen.make("red")

c)

screen.hide("red")

d)

screen.bgcolor("red")

8.

True or False : You can only have one Turtle on the screen.

a)

True

b)

False

9.

An identifier cannot begin with a number. Which of the following is NOT a valid identifier?

a)

num

b)

_num

c)

NUM

d)

1num_

10.

An identifier can begin with an underscore (“_”).

a)

True

b)

False

11.

An identifier can begin with a number.

a)

True

b)

False

12.

In Python, an identifier may begin with an underscore or a letter. Which of the following is a valid identifier? Select all that apply.

a)

_total

b)

2_count

c)

NUM_COUNT

d)

dollar_sign

13.

Which of the following is a valid function call?

a)

forwad)

b)

tu-left()

c)

forward()

d)

forward(;

14.

Select the following function calls that are invalid.

a)

ford)(

b)

$forDS()

c)

forward()

d)

turn_left()

15.

How would you call a function named “my_function”?

a)

Call my_function()

b)

my_function

c)

my_function))

d)

my_function()

16.

Identifiers in Python are case-sensitive.

a)

True

b)

False

17.

78090 is a valid identifier in Python.

a)

True

b)

False

18.

Select the following invalid identifiers. (Identifiers are only allowed to start with an underscore or letter.)

a)

&ident

b)

1ident

c)

_ident

d)

-ident

19.

How would you move an object forward 3 times?

a)

forward() forward() forward()

b)

forward() * 3

c)

Call_forward() 3 times

d)

forward() {3}

20.

You are not able to call the same function twice in a row.

a)

True

b)

False

21.

You can replace the parentheses on a function call with square brackets.

a)

True

b)

False

22.

The parentheses at the end of a function call are optional.

a)

True

b)

False

23.

'''Which of the following is the correct way to start a multi-line comment?

a)

'''

b)

/*

c)

#

d)

//

24.

Both of the following are valid ways to comment code:

Both of the following are valid ways to comment code:

# hello

# world

' ' 'hello world' ' '

a)

True

b)

False

25.

Which of the following comments are correct? Select all that apply.

a)

// hello

b)

# hello

c)

/*he

llo */

d)

//he

llo//

26.

Commented lines affect the execution of your program.

a)

True

b)

False

27.

What is the error in this code?

What is the error in this code?

''' This function does something '''

def foo() :

print("hello world") ''' prin

a)

The single line comment must use # instead of '''

b)

The end of the multi-line comment cannot be on its own line

c)

The beginning and end of the multi line comments are incorrect

d)

All answers are errors in the code

28.

How many blocks will the character move using the following code?

for i in range(1,5) :

forward()

a)

3

b)

4

c)

5

d)

6

29.

Which "for" loop will move your character 5 times?

a)

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

b)

for i in range(5) : forward()

c)

for i in range(1,3) : forward()

d)

for i in range(2,5) : forward()

30.

The following "for" loop has correct syntax.

for rang(1,1) :

forward()

a)

True

b)

False

31.

How many times will “function1” be called?

for i in range(10) :

for j in range(10) :

function1()

a)

25

b)

20

c)

50

d)

100

32.

Which is the correct syntax to make a "for" loop run for all numbers from 0 to 10?

a)

for i in range(1,10) :

b)

for i in range(10) :

c)

for i in range(-10) :

d)

for i in range(11) :

33.

The following loop will go from i = 5 to i = 1.

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

a)

True

b)

False

34.

"For" loops can increment upwards or downwards.

a)

True

b)

False

35.

Choose the following "for" loops that repeat 5 times. Mark all that apply.

a)

for i in range(5)

b)

for i in range(1,5)

c)

for i in range(5,10)

d)

for i in range(10,2)

36.

Select the invalid "for" loops.

a)

for i in range(5) :

b)

for 2 in range(5) :

c)

for i in range() :

d)

for i in range(5,-1) :

37.

How many times will the following "for" loop execute?

for i in range(10,5,-1) :

a)

20

b)

10

c)

5

d)

0

38.

Why should you indent your code?

a)

In Python, the program’s execution changes based on whether you indent or not

b)

Code that is not indented properly will produce syntax errors

c)

It is much easier to read indented code

d)

All of the above

39.

Which of the following makes the character shoot if there is an enemy ahead? Mark all that apply.

a)

if enemy_in_sight() : long_jump()

b)

if not enemy_in_sight() : fire()

c)

if enemy_in_sight() : fire()

d)

if enemy_in_sight() : forward()

40.

The following two pieces of code do the same thing:

if condition :

forward()

# next code

if condition :

forward()

else :

fire()

a)

True

b)

False

41.

You are given three variables, A=True, B=False and C=False. What is the value of the expression A and ( B or C )?

a)

True

b)

False

c)

None

d)

I don't know

42.

Which part of a conditional goes after the if keyword and before the colon?

a)

The word “if”

b)

The word “else”

c)

The code to run

d)

The condition

43.

When would you use an "if-else" statement over an "if" statement?

a)

When you want to stop running code once the condition is false

b)

When you want to run different code if a condition is false

c)

When you want to run code and then check if the condition is true after

d)

They have the exact same function

44.

There is no difference between an "if" statement and an "if-else" statement.

a)

True

b)

False

45.

If you wanted to run different code given different conditions, how would you do that?

a)

Combine all the conditions in one condition using “or”

b)

Use “elif” statements

c)

Put everything in the “else” statement

d)

Create two functions

46.

When running this code, what will the character do if there is an enemy?

if not enemy_in_sight() :

fire()

a)

fire

b)

nothing

c)

walk forward

d)

jump

47.

What would the following code do?

while True :

print(“Hello”)

a)

Print “Hello” once

b)

Print “Hello” infinitely

c)

Do nothing

d)

None of the above

48.

"While" loops always terminate eventually.

a)

True

b)

False

49.

What is the output of this code?

i = 1

while (i < 1) :

print(“hello”)

a)

hello

b)

hello

hello

c)

It will output an error

d)

It won't output anything

50.

When might you use a "while" loop instead of a "for" loop?

a)

If you know exactly how many iterations you want to perform

b)

If you don’t know exactly how many iterations you want to perform

c)

You should always use a "while" loop instead of a "for" loop

d)

You should never use a "while" loop instead of a "for" loop

51.

What is outputted by this code?

while True : break print("Hello") else : print("World")

a)

Hello

b)

Hello

World

c)

It will not output anything

d)

World

52.
This checks whether a condition is true before each time it executes the code inside of it.
a)
"While" Loop
b)
"During" Loop
c)
"Before" Loop
d)
"Fruit" Loop
53.
A programming language that is widely used in web-development. 
a)
Boa
b)
Python
c)
Turtle
d)
Gator
54.
The set of rules that govern how a programming language is structured. 
a)
Syntax
b)
Python
c)
Command
d)
Identifier
55.
When you declare a function, variable, or data structure, you need to give it a name called a(n):
a)
Python
b)
Syntax
c)
Command
d)
Identifier
56.
When you use this symbol in your code, #, you can write notes to yourself that the computer will ignore. These are called:
a)
Syntax
b)
Commands
c)
Comments
d)
Identifiers
57.
This allows you to execute the same code a number of times. (Just the basic one.)
a)
Loop
b)
"For" Loop
c)
Indentation
d)
"Nested" Loop
58.
This lets you execute a code a predetermined number of times. 
a)
Loop
b)
"For" Loop
c)
Indentation
d)
"Nested" Loop
59.
This shows the structure of the code in Python and is not optional. 
a)
Loop
b)
"For" Loop
c)
Indentation
d)
Nesting
60.
A data type that has only 2 possible values, true or false. 
a)
Boolean
b)
Conditional Statement
c)
Assignment Operator
d)
Logical Operator
61.
This checks if a condition is true and then only executes code if true. 
a)
Boolean
b)
Conditional Statement
c)
Assignment Operator
d)
Logical Operator
62.
This takes 1 or 2 Boolean values and returns a Boolean value. 
a)
Boolean
b)
Conditional Statement
c)
Assignment Operator
d)
Logical Operator
63.
This executes the code inside it once before checking whether the condition is true for each subsequent iteration. 
a)
"While" Loop
b)
"Do-while" Loop
c)
"Break" Statement
d)
Infinite Loop
64.
This will stop a loop from iterating before it ends naturally. 
a)
"While" Loop
b)
"Do-while" Loop
c)
"Break" Statement
d)
Infinite Loop
65.
This loop will never stp iterating. 
a)
Infinite Loop
b)
"Break" Statement
c)
"While" Loop
d)
"Do-while" Loop
66.
When you cycle through a loop it is called a(n):
a)
iteration
b)
illiterate
c)
unfortunate event
d)
loop cycle
67.
An instruction that you give the computer. 
a)
Comment
b)
Command
c)
Curtain
d)
Cauliflower
68.
Putting a _ into a name, such as player_scores, is a naming convention called:
a)
python_case
b)
cd_case
c)
snake_case
d)
pillow_case
69.
These are used in computer languages and contain operators that can be used within equations to perform calculations. 
a)
arithmetic operators
b)
denominators
c)
numerators
d)
snake_case
70.
The placing of one loop inside the body of another loop. 
a)
fruit loops
b)
while loops
c)
contained loops
d)
nested loops
71.
Gives the remainder when one number is divided by another. 
a)
dividand
b)
modulus
c)
moderator
d)
EV3
72.
These assign a value on the right side of the operator to the left side. 
a)
assignment operator
b)
Boolean
c)
comparison operator
d)
Boolean finder
73.
These check the value of the L and R sides of operator and return Boolean of T or F. 
a)
Comparison Operator
b)
Nested Conditional
c)
Assignment Operator
d)
Boolean FInder
74.
You can add conditionals within conditionals. 
a)
Bird Nest
b)
Nested Operator
c)
Nested Conditional
d)
Tweety Bird
75.
You can use these to store data like integers, strings, or Booleans. 
a)
Variable
b)
Concatenation
c)
String
d)
Boolean
76.
You can use these to store text such as names or sentences. 
a)
Commands
b)
Variables
c)
Strings
d)
Books
77.
This type of notation is used to identify the elements of any array or list, as well as strings. 
a)
I like turtles. 
b)
Variable
c)
String
d)
Index
78.
Any valid combination of variables, literals, or operators that compute to a single value. 
a)
Expression
b)
Number
c)
Integer
d)
Float
79.
A number that can be written without fractions or decimals. 
a)
Variable
b)
Integer
c)
String
d)
Index
80.
Hexadecimal numbers usually represent colors and are written in...
a)
Base 16 format
b)
Heiroglyphics
c)
French
d)
Cursive
81.
Octal numbers are written in...
a)
Base 8 format
b)
Base 16 format
c)
French
d)
Numerical Order
82.
The order in which the operates in an expression are evaluated to get the expressions value. 
a)
independent practice
b)
operator precedence
c)
statute of limitations
d)
Statue of Liberty
83.
Known in other languages as an array allows a variable to store multiple values in a list format. 
a)
table
b)
list
c)
column
d)
chart
84.
This data type uses named indexes to access elements. It is known as a name-value pair. 
a)
column
b)
list
c)
dictionary
d)
periodic