wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Review - PLTW CSE / Codecademy

Total questions: 53

Worksheet time: 29mins

Name
Class
Date
1.

Find T ?

T=144 / 2 + 5 * 9 - ( 8 -3 )

a)

106

b)

688

c)

112

d)

684

2.

def.number (r1 , r2)

sum = r1 / r2

return sum

a = number (r2 = 15 , r1 = 10)

a)

2 / 3

b)

3 / 2

c)

error

d)

2

3.

Find the Output:

Item = {"ECE" , "CSE" , "EEE" , "CIVIL"}

Item.add (2,"MECH")

print(Item)

a)

{ "ECE" , "MECH" , "CSE" , "EEE" , "CIVIL" }

b)

{ "ECE" , "CSE" , "MECH" , "EEE" , "CIVIL" }

c)

{ "ECE" , "CSE" , "EEE" , "CIVIL" }

d)

{ "ECE" , "CSE" , "EEE" ,"MECH" , "CIVIL" }

4.

what is the output of the following code ?

var1 = 1

var2 = 2

var3 = "3"


print (var + var2 var3)

a)

Error. Mixing operators between numbers and strings are not supported

b)

6

c)

33

d)

123

5.

Which of the following function convert a string to a float in python ?

a)

float(X)

b)

int(x[,base])

c)

long(X[,base])

d)

str(X)

6.

what is the output of the following programing ?

X = [ 'ab' , 'cd' ]

for i in X:

i.upper()

print (x)

a)

[ 'AB' , 'CD' ]

b)

[ 'ab' , 'cd' ]

c)

[ AB , CD ]

d)

ERROR

7.

what will be the output of the following python code snippet ?

not (10 < 20) and not (10 > 30 )

a)

TRUE

b)

FALSE

8.

Find the output ?

a = True

b = False

c = False

if a or b and c :

print "INFYTQ"

else:

print "infytq"

a)

infytq

b)

INFYTQ

c)

ERROR

9.
A(n) float is:
a)
A precise number by including values after the decimal place
b)
A programming statement that directs control flow - it uses BOOLEAN expressions to make a choice between different paths (IF (condition) THEN (path1) ELSE (path2)
c)
A data type that can have only 2 values - TRUE or FALSE
d)
A whole number, it does not have any digits after a decimal.
10.

A(n) integer is:

a)

A programming statement that directs control flow - it uses BOOLEAN expressions to make a choice between different paths (IF (condition) THEN (path1) ELSE (path2)

b)

A precise number by including values after the decimal place

c)

A whole number, it does not have any digits after a decimal.

d)

A data type that can have only 2 values - TRUE or FALSE

11.
A(n) boolean is:
a)
A data type that can have only 2 values - TRUE or FALSE
b)
A whole number, it does not have any digits after a decimal.
c)
A precise number by including values after the decimal place
d)
A programming statement that directs control flow - it uses BOOLEAN expressions to make a choice between different paths (IF (condition) THEN (path1) ELSE (path2)
12.

A(n) variable is:

a)

An action (such as clicking a button) or occurrence (receiving a text message) that happens during runtime that will trigger a response or behavior by the software.

b)

An object such as a number or word. A _____ is an expression that cannot be evaluated any further. Variables are evaluated to a final ____ before operators (arithmetic, relational, or logical) are then used on them.

c)

A type of variable that holds text (characters, numbers, punctuation or math symbols). Uses quotes to tell the computer to not treat what is inside the string (inside the quotes) as code.

d)

The smallest unit of data storage that a program can use.

13.

What does Modulo do

a)

Gives the difference of two numbers

b)

Does simple arithmetic

c)

Give the product when mutiplying

d)

Returns the reminder when divding

14.

What does the following code statement mean "from .models import Question"?

a)

The code statement allows the views.py file to access to your Question data type defined in the models.py file.

b)

The code statement allows the views.py file access to your Question data type defined in the urls.py file.

c)

The code statement allows the views.py file access to your Question data type defined in the admin.py file.

d)

The code statement allows the views.py file access to your Question data type defined in the views.py file.

15.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
16.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
17.
Data type that can only be true or false
a)
int
b)
string
c)
bool
d)
float
18.
A variable that can hold a collection of values, often called an array in other programming languages
a)
list
b)
int
c)
string
d)
constant
19.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
20.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
21.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
22.
Converts a number to a string
a)
str()
b)
int()
c)
parseInt()
d)
convert
23.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
24.
What is python named after
a)
The snake
b)
Television show called Monty Python
25.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
26.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
27.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
28.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
29.
What will the output be from the following code?
print("Hello world!")
a)
SyntaxError
b)
Hello world!
c)
"Hello world!"
d)
print(Hello world!)
30.
What will the output be from the following code?
Print("Hello world!")
a)
NameError
b)
Hello world!
c)
"Hello world"
d)
Print(Hello world!)
31.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
32.
What will the output be from the following code?
print(3*4)
a)
34
b)
7
c)
12
d)
3*4
33.
What will the output be from the following code?
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
34.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
35.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
36.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
37.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
38.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
39.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
40.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
41.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
42.
What will be the output?
name = 'Dave'
greeting = "Good morning" + name
print (greeting)
a)
Good moning 'Dave'
b)
Good morning Dave
c)
Good morning name
d)
Good morning + Dave
43.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
44.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
45.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)
SyntaxError
d)
Hello world!
46.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
47.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
48.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

49.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
50.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
51.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
52.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
53.

people = ["John", "Rob", "Bob"]

print (people[4])

what would this result be?

a)
John
b)
Rob
c)
Bob
d)
Error