NEW
Font size
WorksheetsPython L1 Concepts
Total questions: 40
Worksheet time: 21mins
Which is the correct file extension for saving Python files?
.txt
.scr
.py
No Extention
Which of the below statements is equal to:
sum = sum + number
sum = sum ++ number
sum += number
sum += sum + number
number += sum
Which of the following is NOT a valid ‘for’ loop?
for var in [1, 2, 3, 4]:
for var in range(1):
for var in range(1,2,3):
for var in range(1,2,3,4,5):
Which of the following is a ‘count-controlled’ loop?
for
while
if
else
Which of the following is a ‘condition-controlled’ loop?
for
while
if
else
Which of the following is NOT a valid ‘if’ statement?
if x < 5:
if x < 5 and x > 5:
if x = 5:
if x in [2, 3, 4]:
What does input() do?
It converts a value to a string
It allows a user to input data
It checks equality of what is input to the function
It executes python code that a user submits
What is the correct syntax for writing a variable in Python?
my_variable = 10
my variable = 10
my_variable is 10
my_variable: 10
What is the built-in Python function that converts a number to a string?
str()
int()
parseint()
convert()
What symbol do you use to make a comment in Python?
@
~
;
#
What is the Python built-in function used to display numbers and text on the screen?
print()
input()
output()
command()
Which of the following is a valid variable name?
my var 1
1var
my_var_1
my-var
Which best describes what a "variable" is in python?
A value we get from the user
A numerical value we can do operations on to change its value
A named container for storing a piece of information
A named piece of code that executes when called
What is the term for the number or word that we assign to a variable?
Value
Bug
Information
Text
Which code turns the turtle so it is facing the opposite direction?
my_turtle.right(90)
my_turtle.left(180)
my_turtle.left(360)
my_turtle.backward(180)
Which code makes the turtle go faster?
my_turtle.forward(100)
my_turtle.set_speed(100)
my_turtle.speed(10)
my_turtle(speed=1)
Which of the following is the correct conditional statement to determine whether y is in the range 10 through 50, inclusive?
if 10 < y or y > 50:
if y >= 10 or y <= 50:
if 10 > y and y < 50:
if y >= 10 and y <= 50:
Which of the following is the correct conditional statement to determine whether ‘choice’ is a number other than 10?
if choice <> 10:
if choice < 10 or choice >= 10:
if choice != 10:
if choice == 10:
In Python, the ____ symbol is used as the not-equal-to operator.
<>
==
!=
<=
What will always be the index of the last item in a list?
-0
-1
0
1
Which function will add an item to a list?
my_list.add(item)
my_list.append(item)
my_list.concat(item)
my_list.insert(item)
To use Python’s turtle graphics, you must include which of the following statements in your program?
import turtle_graphics
import turtle
import turtle_module
import Turtle
The Python turtle is initially positioned in the _____ of a graphics window.
center
top
right
left
By default, the Turtle heads in the _____ direction.
Up
Down
Right
Left
Which of these is true about scope?
global is inside built-in which is inside local
built-in is inside local which is inside global
local is inside global which is inside built-in
python doesn't have scope
What do parameters do?
pass values into a function
return one value from the end of a function
store the name of the function
They are the guidelines you follow to make a function
How can the following function be called?
(You may select more than one answer)
def func(a, b, c):
func(a = 1, b = 1, c)
func(a = 1, 1, 1)
func(1, 2, 4)
func(1, b = 2, 4)
What is a Python class?
A function to create an object
A procedure to create an object
A template or blueprint for creating objects
A process that repeats what's directed
Identify the code that properly creates an instance of a class named Car
tesla = car.make()
mustang = Car(make, model)
camaro.car(make, model)
porche = car.make.model()
What are class variables?
Variables that change with every instance of the class
Variables that apply to all instances of the class
Values that are passed in when creating a new object
Variables that can only be changed through python functions
Which is the best definition of what an "object" is in python?
A standard data type that works like a list
A blueprint that defines the structure of a class, including its variables and functions
A variable that starts with self. and belongs to a class
A specific instance or member of a class that has its own variables and functions
Which is the proper way to write the initialization method of a class?
def init My_Class(self):
def __init__(self):
def _init_ My_Class(self):
def init (self):
How can we access the value of the instance variable named speed belonging to an object named my_player?
my_player(speed)
my_player.speed
my_player().speed
my_player.speed()
How can we call the start method of an object named my_player?
my_player(start)
my_player.start
my_player().start()
my_player.start()
When creating a flowchart to model a program, a diamond shape usually represents a:
terminator (the start or end of the program)
process
decision
variable
Which is true about python programs?
You can only have one class per python file
Code in a function is not run until the function is called
An object cannot contain another object as a variable
You have to call the __init__ method of an object after it is created
What is pseudocode?
It means 'false code' and is the name given to code that has errors in it
It is a plan of a program written in words that resemble code
It is an object-oriented language that is easier to read than python
It is a style of writing comments that help the user to understand what is going on in the program
Why are flowcharts useful?
They allow us to visualize the logic of our program
They make it easier to explain your code to others
They help you to understand when to use functions and flow controls when writing the program
All of these are reasons why flowcharts are useful
How can we make sure our program ignores capitalization when comparing text input?
Ask the user to follow the capitalization pattern that you coded
Create if statements to check for every likely capitalization pattern
Ignore text that isn't capitalized the same way as you wrote it
Use .lower() to change the input string to lowercase and then compare
What does the int() function do?
Determines if something is an integer and returns True or False
Turns a string into an integer
Creates an integer with no value
Turns a number or a string containing only numbers into an integer
