wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python basics

Total questions: 60

Worksheet time: 31mins

Name
Class
Date
1.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
2.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
3.
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
4.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
5.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
6.
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
7.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
8.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
9.

Which is the Python logo?

a)
b)
c)
d)
10.

What is a input?

a)

A function that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

11.

What is a output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

A orange

12.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

13.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

14.

What is pseudocode?

a)

A planning tool that resembles code but is not code used for humans.

b)

Syntax code

c)

A programming language.

d)

A pastry.

15.

Why would you use a loop?

a)

To repeat a piece of code

b)

To create a loop

c)

To input data

16.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
17.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
18.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
19.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
20.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
21.
Data type that can only be true or false
a)
int
b)
string
c)
bool
d)
float
22.
What will the output be from the following code?
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
23.

Which is the correct operator for power  xyx^y  

a)

x^y

b)

x**y

c)

x^^y

d)

None of these

24.

What is the answer to this expression, 22%3 is

a)

7

b)

1

c)

0

d)

5

25.

Which one of theses is floor division

a)

/

b)

//

c)

%

d)

None of theses

26.

What is the order of precedence in Python?

i. Parenthesis

ii. Exponential

iii. Multiplication

iv. Division

v. Addition

vi. Subtraction

a)

i, ii, iii, iv, v, vi

b)

ii, i, iii, iv, v, vi

c)

ii, i, iv, iii, v, vi

d)

i, ii, iii, vi, v, iv

27.

Which of the following is true for variable names in python?

a)

Unlimited Length

b)

all private members must have leading and trailing underscores

c)

underscores and ampersand are only two special characters allowed

d)

None of these

28.
How would you assign an integer to a variable?
a)
new_var = 4
b)
new_var == 4
c)
new_var = "4"
d)
new var "4"
29.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
30.
To create a variable named new_var and assign it a value of 81 divided by 9, which statement would you use?
a)
new_var = 81 \ 9
b)
new_var = "81 / 9"
c)
new_var = "81 \ 9"
d)
new_var = 81 / 9
31.
What does an IF statement do?
a)
Closes the program
b)
Makes a decision
c)
Asks a question
32.

Data type for a whole number

a)

Float

b)

Boolean

c)

Integer

d)

String

33.

A Python data type that holds positive and negative whole numbers

a)

String

b)

int

c)

str

d)

input

34.

The Boolean operator that returns true if EITHER of its operands are true

a)

and

b)

or

c)

not

d)

equal

35.

print(boolean(None, "String", False, "False", 0,"value")

What is the output?

a)

False, True, True, False, False, True

b)

False, True, False, True, False, True

c)

True, True, False, False, True, False

d)

False, False, True, True, False, True

36.

Which of the following pieces of code defines a list of all the numbers from 4 to 12?

a)

range(4,12)

b)

range(4, 13)

c)

range( 3,12)

d)

range(3, 13)

37.

Why did Guido van Rossum call his programming language Python?

a)

He thinks Pythons were cool

b)

He couldn't think of anything else

c)

A friend suggested it

d)

He loves Monty Python

38.

What is concatenation?

a)

Replacing a string variable with another string variable

b)

Combining two variables such as first name and last name

c)

One of the food options in the canteen on Friday

d)

A large collection of cats in an open space

39.

What does != represent?

a)

Possibly equal to

b)

Not equal to

c)

Check for error

d)

Don't assign a value

40.

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

print (people[4])

what would this result be?

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

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
42.
What button do you press to compile (run) your program so that it runs in the shell?
a)
F3
b)
F5
c)
F7
d)
F9
43.

Which of the below operators can be used to compare two numbers

a)

==

b)

><

c)

=

44.

How is a block of code defined in Python ?

a)

with indentation

b)

with paranthesis

c)

with curly braces

45.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
46.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
47.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
48.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
49.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

50.

List items have an index number. In the following list, which item has the index number of 3?

["Barry", "Harry", "Jesse", "John", "Peter", "Harry"]

a)

"Barry"

b)

"Harry"

c)

"Jesse"

d)

"John"

51.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
52.
What will the following code result in:

name = “Alison”
number = len(name)
print(number)
a)
4
b)
5
c)
6
d)
7
53.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
54.

Valid variable names are:

a)

current-balance

b)

Current Balance

c)

account4

d)

4account

e)

current_balance

55.

The symbols >>> are called

a)

much greater than

b)

the interactive prompt

c)

command

d)

string

56.

When designating a variable, if more than one word is used, there needs to be a(n) ____________________ between the words

a)

space

b)

hyphen (-)

c)

hashtag (#)

d)

underscore (_)

57.

Which code prints the output [3,7,8] for a given list -

[ [1,2,3] , [5,6,7] , [0,9,8] ]

a)

[i[2] for i in list]

b)

[i(2) for i in list]

c)

[i[3] for i in list]

d)

(i(3) for i in list)

58.

What will be the output of the following Python code?

str1 = 'hello'

str1=str1+2

a)

hello2

b)

Error

c)

hello

d)

hello 2

59.

What is the default data type of input()?

a)

string

b)

int

c)

depends what is entered

d)

list

60.

Is this a valid example of the Input-Process-Output Model?

Input: Text and numbers typed on keyboard.

Process: Calculations performed in a spreadsheet.

Output: Bank record.

a)

Yes.

b)

No.

c)

I don't know.