wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python L1 Concepts

Total questions: 40

Worksheet time: 21mins

Name
Class
Date
1.

Which is the correct file extension for saving Python files?

a)

.txt

b)

.scr

c)

.py

d)

No Extention

2.

Which of the below statements is equal to:

sum = sum + number

a)

sum = sum ++ number

b)

sum += number

c)

sum += sum + number

d)

number += sum

3.

Which of the following is NOT a valid ‘for’ loop?

a)

for var in [1, 2, 3, 4]:

b)

for var in range(1):

c)

for var in range(1,2,3):

d)

for var in range(1,2,3,4,5):

4.

Which of the following is a ‘count-controlled’ loop?

a)

for

b)

while

c)

if

d)

else

5.

Which of the following is a ‘condition-controlled’ loop?

a)

for

b)

while

c)

if

d)

else

6.

Which of the following is NOT a valid ‘if’ statement?

a)

if x < 5:

b)

if x < 5 and x > 5:

c)

if x = 5:

d)

if x in [2, 3, 4]:

7.

What does input() do?

a)

It converts a value to a string

b)

It allows a user to input data

c)

It checks equality of what is input to the function

d)

It executes python code that a user submits

8.

What is the correct syntax for writing a variable in Python?

a)

my_variable = 10

b)

my variable = 10

c)

my_variable is 10

d)

my_variable: 10

9.

What is the built-in Python function that converts a number to a string?

a)

str()

b)

int()

c)

parseint()

d)

convert()

10.

What symbol do you use to make a comment in Python?

a)

@

b)

~

c)

;

d)

#

11.

What is the Python built-in function used to display numbers and text on the screen?

a)

print()

b)

input()

c)

output()

d)

command()

12.

Which of the following is a valid variable name?

a)

my var 1

b)

1var

c)

my_var_1

d)

my-var

13.

Which best describes what a "variable" is in python?

a)

A value we get from the user

b)

A numerical value we can do operations on to change its value

c)

A named container for storing a piece of information

d)

A named piece of code that executes when called

14.

What is the term for the number or word that we assign to a variable?

a)

Value

b)

Bug

c)

Information

d)

Text

15.

Which code turns the turtle so it is facing the opposite direction?

a)

my_turtle.right(90)

b)

my_turtle.left(180)

c)

my_turtle.left(360)

d)

my_turtle.backward(180)

16.

Which code makes the turtle go faster?

a)

my_turtle.forward(100)

b)

my_turtle.set_speed(100)

c)

my_turtle.speed(10)

d)

my_turtle(speed=1)

17.

Which of the following is the correct conditional statement to determine whether y is in the range 10 through 50, inclusive?

a)

if 10 < y or y > 50:

b)

if y >= 10 or y <= 50:

c)

if 10 > y and y < 50:

d)

if y >= 10 and y <= 50:

18.

Which of the following is the correct conditional statement to determine whether ‘choice’ is a number other than 10?

a)

if choice <> 10:

b)

if choice < 10 or choice >= 10:

c)

if choice != 10:

d)

if choice == 10:

19.

In Python, the ____ symbol is used as the not-equal-to operator.

a)

<>

b)

==

c)

!=

d)

<=

20.

What will always be the index of the last item in a list?

a)

-0

b)

-1

c)

0

d)

1

21.

Which function will add an item to a list?

a)

my_list.add(item)

b)

my_list.append(item)

c)

my_list.concat(item)

d)

my_list.insert(item)

22.

To use Python’s turtle graphics, you must include which of the following statements in your program?

a)

import turtle_graphics

b)

import turtle

c)

import turtle_module

d)

import Turtle

23.

The Python turtle is initially positioned in the _____ of a graphics window.

a)

center

b)

top

c)

right

d)

left

24.

By default, the Turtle heads in the _____ direction.

a)

Up

b)

Down

c)

Right

d)

Left

25.

Which of these is true about scope?

a)

global is inside built-in which is inside local

b)

built-in is inside local which is inside global

c)

local is inside global which is inside built-in

d)

python doesn't have scope

26.

What do parameters do?

a)

pass values into a function

b)

return one value from the end of a function

c)

store the name of the function

d)

They are the guidelines you follow to make a function

27.

How can the following function be called?

(You may select more than one answer)


def func(a, b, c):

a)

func(a = 1, b = 1, c)

b)

func(a = 1, 1, 1)

c)

func(1, 2, 4)

d)

func(1, b = 2, 4)

28.

What is a Python class?

a)

A function to create an object

b)

A procedure to create an object

c)

A template or blueprint for creating objects

d)

A process that repeats what's directed

29.

Identify the code that properly creates an instance of a class named Car

a)

tesla = car.make()

b)

mustang = Car(make, model)

c)

camaro.car(make, model)

d)

porche = car.make.model()

30.

What are class variables?

a)

Variables that change with every instance of the class

b)

Variables that apply to all instances of the class

c)

Values that are passed in when creating a new object

d)

Variables that can only be changed through python functions

31.

Which is the best definition of what an "object" is in python?

a)

A standard data type that works like a list

b)

A blueprint that defines the structure of a class, including its variables and functions

c)

A variable that starts with self. and belongs to a class

d)

A specific instance or member of a class that has its own variables and functions

32.

Which is the proper way to write the initialization method of a class?

a)

def init My_Class(self):

b)

def __init__(self):

c)

def _init_ My_Class(self):

d)

def init (self):

33.

How can we access the value of the instance variable named speed belonging to an object named my_player?

a)

my_player(speed)

b)

my_player.speed

c)

my_player().speed

d)

my_player.speed()

34.

How can we call the start method of an object named my_player?

a)

my_player(start)

b)

my_player.start

c)

my_player().start()

d)

my_player.start()

35.

When creating a flowchart to model a program, a diamond shape usually represents a:

a)

terminator (the start or end of the program)

b)

process

c)

decision

d)

variable

36.

Which is true about python programs?

a)

You can only have one class per python file

b)

Code in a function is not run until the function is called

c)

An object cannot contain another object as a variable

d)

You have to call the __init__ method of an object after it is created

37.

What is pseudocode?

a)

It means 'false code' and is the name given to code that has errors in it

b)

It is a plan of a program written in words that resemble code

c)

It is an object-oriented language that is easier to read than python

d)

It is a style of writing comments that help the user to understand what is going on in the program

38.

Why are flowcharts useful?

a)

They allow us to visualize the logic of our program

b)

They make it easier to explain your code to others

c)

They help you to understand when to use functions and flow controls when writing the program

d)

All of these are reasons why flowcharts are useful

39.

How can we make sure our program ignores capitalization when comparing text input?

a)

Ask the user to follow the capitalization pattern that you coded

b)

Create if statements to check for every likely capitalization pattern

c)

Ignore text that isn't capitalized the same way as you wrote it

d)

Use .lower() to change the input string to lowercase and then compare

40.

What does the int() function do?

a)

Determines if something is an integer and returns True or False

b)

Turns a string into an integer

c)

Creates an integer with no value

d)

Turns a number or a string containing only numbers into an integer