wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python basics

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

Python is....................

a)

Open source programming language

b)

Paid programming language

2.

What is the correct name for this symbol?


==

a)

Assignment

b)

Equal to

c)

Greater than

d)

Less than

3.

What will this symbol do?


\n

a)

Print

b)

Not

c)

New line

d)

Does nothing

4.

What does this symbol represent?


>

a)

Less than

b)

Greater than

c)

Equal to

d)

Less than or equal to

5.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

6.
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!
7.

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

8.
What is python named after
a)
The snake
b)
Television show called Monty Python
9.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
10.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
11.
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
12.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

13.

If the coding steps are in the incorrect order, the computer can still execute the program.

a)

True

b)

False

14.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

15.
a)

2

b)

0

c)

1

d)

4 / 2

e)

Error

16.

Predict output for the following code snippet.

print('No pain, no gain'.split('a'))

a)

['No pain', ' no gain']

b)

['No p', 'in, no g', 'in']

c)

['No', 'pain,', 'no', 'gain']

d)

['No pai', ', ', 'o gai', '']

17.

What is the name of the built-in command in python to output data?

a)
print
b)
input
c)

Print

d)

display

18.

What is a input?

a)

A built-in function that allows us to prompt the user to enter data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A device.

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 is the proper syntax for Python comments?

a)

<!-- Python comment -->

b)

<comment> Python comment <comment>

c)

# Python Comment

d)

/* Python Comment */

21.
What symbol is used in python to assign values to a variable?
a)

=

b)

c)

==

d)

*

22.
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)

Syntax Error

d)
Hello world!
23.
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)

Syntax Error

24.

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

a)

Converts the variable myAge to a integer

b)

Syntax Error

c)

Converts the variable myAge from a integer to a string

d)

Missing input

25.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
26.

Are Double or single quotes used in Python?

a)

Double

b)

Single

c)

Neither

d)

Both work

27.

Which of the following assign the value 50 to a variable x?

a)

x=50

b)

Let x=50

c)

x;=50

d)

x<<50

28.

Python correct naming convention for variables is?

a)

new_user25

b)

NewUser25

c)

25_new_user

d)

25NewUser

e)

NEWUSER25

29.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

d)

4

30.
What will the output be from the following code?
print("Hello" + 2 + "world")
a)
Hello 2 world
b)
Hello2world
c)
TypeError
d)
HelloHelloworld
31.
What will the output be from the following code?
Print("Hello world!")
a)

Name Error

b)
Hello world!
c)
"Hello world"
d)
Print(Hello world!)
32.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
33.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
34.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

35.

What will be the output for following python programme:

x = 100

y = float(x)

print(y)

a)

200

b)

100.0

c)

100

d)

Can't convert an integer to a floating number.

36.

Which of the following is the slicing operator?

a)

[ ]

b)

{ }

c)

( )

d)

/

37.

What is the output of the following lines of code?

var1 = 12

var1 = 23.4

var1 = "I love AI!"

print(var1)

a)

12

b)

23.4

c)

I love AI!

d)

Error

38.

What is the output from the following lines of code?

a = [2, 4, 8]

a[2] = 6

print(a)

a)

[2, 4, 8]

b)

[2, 6, 8]

c)

[2, 4, 6]

d)

[6, 4, 8]

39.

Which function allows us to add one element to a list at a desired location?

a)

append()

b)

extend()

c)

insert()

d)

pop()

40.

How many parameters are there in the sum() function call below?

sum(1, 3, 5)

a)

0

b)

1

c)

2

d)

3

41.

How many times would the while loop execute?

a)

0

b)

1

c)

2

d)

3

42.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
43.
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
44.
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
45.

Which is the Python logo?

a)
b)
c)
d)
46.

_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"

a)

int

b)

float

c)

char

d)

String

47.

Which if the values below is an integer data type?

a)

1

b)

1.0

c)

1/2

d)

"1"

48.

Which value is a Boolean?

a)

64

b)

"Cat"

c)

True

d)

0.5

49.

Lists are used to store single item in a single variable.

a)

True

b)

False

50.

List items are indexed, the first item has index [1], the second item has index [2] etc.

a)

True

b)

False

51.

List items are ordered, changeable, and allow duplicate values.

a)

True

b)

False

52.

Lists are created using square brackets:

a)

True

b)

False

53.

what is the correct order?

a)

3,1,6,7,2,4,5

b)

6,3,1,2,4,5,7

c)

3,6,1,2,4,5,7

d)

3,6,2,5,1,4,7

54.

what is the output of the given code?

a)

This car is awesome. The car wins the race

b)

This car is awesome

c)

The car wins the race

d)

Error

55.

choose the correct way to access value 20 from the following tuple

aTuple=("Orange",[10,20,30],(5,15,25))

a)

aTuple[1:2][1]

b)

aTuple[1:2](1)

c)

aTuple[1][1]

56.

What does the following comparison operator “==” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

57.

What is the name of the following logical operator?

Returns True if one of the statements is true

(a)  

58.

What is the result of the following condition if:

A = 30

B = 21

C = 71

B != A or C < A

a)

True

b)

False

59.
Arithmetic Operators
What is a % ?
a)
Multiplication
b)
Division
c)
Modulo
d)
Increment
60.
Stores True or False
a)
INTEGER
b)
REAL (Float)
c)
STRING
d)
BOOLEAN