Font size
WorksheetsPython for Middle School
Total questions: 95
Worksheet time: 44mins
Python is a
text language
database language
programming language
Python has a simple syntax similar to the
coding language
english language
spanish language
Code for Hello, World!
print Hello, World!
print("Hello, World!)
print("Hello, World!")
Code for
Five is greater than two!
if 5 > 2:
print("Five is greater than two!")
if 5 = 2:
print("Five is greater than two!")
if 5 > 2: Print("Five is greater than two!")
Code for
257
Hello, World!
x = 257
y = "Hello, World!"
print(y)
print(x)
x = 257
y = "Hello, World!"
print(x)
print(y)
x = 257
y = Hello, World!
print x
print y
Insert the missing part of the code below to output
_________________ "My name is ".
Comments in Python are written with a special character, which one?
brackets
hashtag
coma
Code for
b is greater than a
a = 33
b = 200
if b > a:
print("b is greater than a")
a = 33
b = 200
if b < a:
print("b is greater than a")
a = 330
b = 200
if b > a:
print("b is greater than a")
Python language use
upper case letters
lower case letters
upper and lower case letters
The output of the program
x = 4
x = "Sally"
print(x)
four
Saly
Sally
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
It displays an output
What is the Python built-in function used to display numbers and text on the screen?
input
output
command
holds whole numbers
holds a decimal point in a number
What is the output from the following code?
print ("hello world")
The requirements for printing a string in Python are:
( ) , ! and " "
( ) and !
( ) and " "
" " and !
print("Hello world!\nHello world!")
Hello world!
print("Hello" + str(2) + "world!")
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
print(Hello world!)
print("Hello world!" * 2)
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
Which of the following functions display an output to the screen?
display()
output()
print()
post()
Everything that we want to display in a print() function must:
be inside parentheses - ()
quotation marks - ""
be inside single quotation marks - ''
be inside hash marks - #
Which operator performs a multiplication?
+
/
X
*
Which operator performs a division?
-
+
/
*
Which operator performs an addition?
-
+
==
/
Which operator checks if a value is equal to another value?
+
=
==
!=
What will:
answer = input("Give me a number")
print(answer * 5)
output?
An error message
The value of answer multiplied by 5
answer * 5
The value of answer repeated 5 times
Which of these is true?
A syntax error will stop a program running
A logic error will stop a program running
A syntax error will let the program run but may have unexpected outcomes
The program will always show an error message for a logic error
name = 'Dave'
print (name)
Which of the following functions display an output to the screen?
display()
output()
print()
post()
Everything that we want to display in a print() function must:
be inside parentheses - ()
quotation marks - ""
be inside single quotation marks - ''
be inside hash marks - #
Which operator performs a multiplication?
+
/
X
*
Which operator performs a division?
-
+
/
*
Which operator performs an addition?
-
+
==
/
Which operator checks if a value is equal to another value?
+
=
==
!=
What will:
answer = input("Give me a number")
print(answer * 5)
output?
An error message
The value of answer multiplied by 5
answer * 5
The value of answer repeated 5 times
Which of these is true?
A syntax error will stop a program running
A logic error will stop a program running
A syntax error will let the program run but may have unexpected outcomes
The program will always show an error message for a logic error
name = 'Dave'
print (name)
How many variables are there in this program?
2
3
4
5
What would be the output of this program if the user input was 10?
22.04
220.4
2204
Error wrong data type
What operator is being used in this program?
less than
greater than
less than or equal to
greater than or equal to
What type of list is being used in this example?
Dictionary
List
Tuple
2d Array
Which of the following statements apply to tuples?
They are created using square brackets
They are created using curved brackets
They can be amended when the program is running
They can not be amended when the program is running
What would be the output of this program if the user entered "yes" then "what"?
Enjoy your day
it is too windy for an umbrella
Take an umbrella
Error
What would be the output of this program if the user entered "Alien"
Alienway
wayAlien
lienAay
ayAlien
What data type represents a whole number?
Float
Int
Boolean
String
What data type represents a decimal number?
Float
Int
Boolean
String
What data type represents characters?
Float
Int
Boolean
String
What data type represents only two possible outcomes?
Float
Int
Boolean
String
What you the output of this program be if the user guessed "h"?
Error
It was heads
It was tails
Bad luck
What shape would this code produce?
5 pointed star
Pentagon
Sqaure
Nothing it would give an error
Is the following subprogram a function or procedure?
Function
Procedure
What type of loop is being used in this program?
Count controlled
Condition Controlled
How many errors are there in this code?
1
2
3
4
How many errors are there in this piece of code?
0
1
2
3
Which of these is the best description of a list in Python?
A list is a collection of data that has an order and can be changed
A list is a lot of variables
A list is used for shopping
A list is a collection of data that cannot hold duplicated data and cannot be changed
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
