wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basis (S3)

Total questions: 41

Worksheet time: 21mins

Name
Class
Date
1.

How would you assign an integer to a variable?

a)

new_var = int(4)

b)

new_var == 4

c)

new_var = "4"

d)

new var = "4"

2.

How would you print a text string?

a)

output "Hello!"

b)

print ("Hello!")

c)

print (Hello!)

d)

output (Hello!)

3.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
4.
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
5.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
6.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
7.
Numbers with a decimal point belong to a type called...
a)
pointing
b)
integers
c)
decimal
d)
float
8.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
9.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
10.

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

11.

What symbol is used in Python to assign values to a variable?

a)

equals =

b)

plus +

c)

forward slash /

d)

asterisk *

12.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
13.

What will be the output?
name = 'Dave'
print(name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

14.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
15.

Which is the Python logo?

a)
b)
c)
d)
16.

What is an 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.

17.

What is an output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

An orange

18.

What function is used to output a message in Python?

a)

print("")

b)

input=name

c)

print

d)

name=input

19.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

20.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
21.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
22.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
23.

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.

24.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
25.

Which of these is a string?

a)

42

b)

True

c)

"This one!"

d)

No, this one.

26.

How do you define (assign) variables?

a)

var="String"

b)

func==Hello

c)

var : 123

d)

word= Hello

27.

How to create a numeric variable age with a value of 10

a)

age = 10

b)

age = int(10)

c)

age = "10"

28.

In Python, "Hello World" is the same as 'Hello World'

a)

True

b)

False

29.

age = '5'


In the code above, age is a

a)

string

b)

integer

c)

floating point

30.

How do you take input from the user?

a)

input()

b)

scanf()

c)

console()

d)

all of the above

31.

Which is a valid identifier?

a)

0hello

b)

myfile

c)

break

d)

hello world

32.

Improper tab placement will prevent a block of code from running properly.

a)

True

b)

False

33.

A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.

a)

True

b)

False

34.

Look at the following code, what will it generate?

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

35.

What is the output?

a)

1,2,3,4,5

b)

0,1,2,3,4

c)

1,2,3,4

d)

5,4,3,2,1

36.

How many hallos will be printed?

a)

5

b)

None

c)

4

d)

6

37.
What is iteration known as?
a)
Looping
b)
Crashing
c)
Repeating
38.

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

39.

Which of the following programs prints ten lines?

a)

for i in range(10):

print("hi")

b)

for i = 1 to 10:

print("hi")

c)

for i in 1 - 10:

print("hi")

d)

for i from 0 to 9:

print("hi")

40.

What would be the output of the following code:

for i in range(3):

print(5)

a)

0 1 2

b)

3 3 3 3 3

c)

5 5 5

d)

0 1 2 3 4

41.

What would be the output of the following code:

for i in range(3):

print(i)

a)

1 2 3

b)

i i i i

c)

i i i

d)

0 1 2