Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 148

Worksheet time: 1hrs 26mins

Name
Class
Date
1.

What is a programming language?

a)

Written English

b)

An artificial language used to program a computer

c)

A language used in pseudocode

d)

Machine code

2.

What is a program?

a)

A series of a step-by-step instructions that tell a computer how to solve a task

b)

A video that is watched on a computer

c)

A flowchart written on a computer

d)

The make and model of a computer

3.

What does the print command do?

a)

Outputs a hard copy of a program to a printer

b)

Outputs a message on screen

c)

Print a hard copy of a flow chart to a printer

d)

Prints out the the commands line by line on the screen

4.

How do we get user input from the keyboard?

a)

input = (What is your name?)

b)

input = What is your name?

c)

output = ("What is your name?")

d)

input("What is your name? ")

5.

Which data type is the most suited to store a telephone number in a variable?

a)

string

b)

integer

c)

float

d)

boolean

6.

Which data type would you use for the quantity of stock in a shop?

a)

integer

b)

float

c)

string

d)

boolean

7.

If you want to change the data type to an integer which line of code would you use?

a)

int ("How much pocket money do you have?")

b)

input("How much pocket money do you have?")

c)

int(input("How much pocket money do you have?"))

d)

int = ("How much pocket money do you have?")

8.

What is an instruction?

a)

A box in a flowchart

b)

A calculation performed in a programming language

c)

One or more statements grouped together to instruct the computer to perform a task

d)

A separate file that has information on how to install the program

9.

What is a statement?

a)

A calculation performed in a programming language

b)

A box in a flow chart

c)

A keyword in a programming language

d)

A printout of the program

10.

How many statements are in this line of code?

print("If I do well in computing, I will find most subjects easy")

a)

2 - print and if

b)

0 - there are no statements

c)

1 - print

11.

Why was Python (TM) developed?

a)

To go back to the old way of programming

b)

To create a programming language for students in grade school

c)

To make it easier to learn Java

d)

Python was developed by accident

12.

Python (TM) is owned and managed by

a)

Microsoft (c)

b)

Sun Microsystems (c)

c)

Python (TM) is open source and free to use

d)

Google (c)

13.

Python is ___________ level programming language and is ___________.

a)

High, compiled

b)

High, interpreted

c)

Low, compiled

d)

Low, interpreted

14.

Generally speaking, a low level programming language is easier to read, write and maintain over a high level programming language

a)

True

b)

False

15.

The syntax in Python (TM) is one of the main advantages over other high level programming languages.

a)

True

b)

False

16.

A statement in programming

a)

Expresses an action to be carried out

b)

Always returns results like expressions

c)

Rules controlling how components in a program are combined

d)

An instruction to perform a task, usually one word

17.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

18.

A block is

a)

a statement including elements of a command

b)

the structure and form of the code

c)

source code that is grouped together

d)

meaning assigned to symbols, characters and words

19.

What symbol comes before a comment?

a)

$

b)

>>

c)

#

d)

!

20.

An exception is

a)

the structure of form of the code

b)

the meaning of the characters and words in the code

c)

the statement that is missing from the instructions

d)

an event occurring during execution of a program which disrupts the flow of the program's instructions

21.

Debugging is

a)

how characters are arranged in a statement

b)

detecting or removing errors from a program

c)

removing viruses from a computer

d)

the meaning of each of the characters and symbols in the program

22.

A disadvantage of Python is it is harder to debug than other higher level programming languages.

a)

True

b)

False

23.

In programming, a (n) _______________ is a value that can change, depending on conditions or on information passed to the program

a)

string

b)

block

c)

instruction

d)

variable

24.

Generally speaking Python (TM) would run _____________ than C++ and take ____________ time to create

a)

faster, less

b)

faster, more

c)

slower, less

d)

slower, more

25.

Since Python (TM) is open source,

a)

Support for using Python (TM) is easy to find

b)

It is free

c)

There is a large catalog of supporting documents

d)

it is a less powerful programming languange

26.

What is the word (command) used to display output within Python?

a)

print

b)

input

c)

output

d)

display

27.

What is a variable?

a)

A box(memory location) where you store values

b)

A box(memory location) where you store multiple values

c)

Data type

d)

A static memory value

28.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
29.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
30.

Which of these would work as a piece of code in Python?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":

31.

What function is used to output a message in python?

a)

print ("")

b)

print = ("")

c)

print

d)

Print ("")

32.

What syntax would you use to create a name variable in Python?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

33.

If you want multiple options for your code, what should you use (after if)?

a)

elif

b)

else

c)

if

34.

Returns the remainder from division.

a)

DIV

b)

MOD

35.

A data type consisting of numbers with decimals.

a)

integer

b)

float / real

c)

string

d)

boolean

36.

A data type consisting of whole numbers.

a)

integer

b)

float / real

c)

string

d)

boolean

37.

A data type consisting of a single character.

a)

integer

b)

character

c)

string

d)

boolean

38.

Which command will display the text 'Hello world!' on the screen?

a)

print(Hello world!)

b)

print "Hello world!"

c)

print("Hello world!")

d)

print = "Hello world!"

39.

Which command will correctly ask the user for their age?

a)

age = input("How old are you?")

b)

age = input(How old are you?)

c)

input("How old are you?") = age

d)

How old are you = input()

40.

Which decision statement will be triggered if the variable x is less than 20?

a)

if x > 20:

b)

if x <> 20:

c)

if x == 20:

d)

if x < 20:

41.

Which of these tests whether the variable x is the same as 'Hello'?

a)

x = "Hello"

b)

x != "Hello"

c)

x == "Hello"

d)

x <> "Hello"

42.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

43.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

44.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

45.

What would the output of this code be if the user entered the value 70?

a)

Pass

b)

Fail

c)

Merit

d)

Distinction

46.

What would the outcome of this program be?

a)

22

b)

50

c)

Nothing, it won't run due to errors in the code

d)

38

47.

What would the outcome of this program be?

a)

prints 1 to 10 numbers

b)

prints 10 to 1 numbers

c)

prints 1 to 15 numbers

d)

prints 1 to 14 numbers

48.

What would the outcome of this program be?

a)

prints 5 to 50 numbers

b)

prints 5 to 49 numbers

c)

prints 5 to 55 numbers

d)

prints multiples of 5 upto 50

49.

What is the output of the following program?

for i in range(0, 5):

print(i)

i=i+1

a)

1 to 5 numbers

b)

1 to 4 numbers

c)

0 to 4 numbers

d)

0 to 5 numbers

50.

What is the output of the following piece of code when executed in Python shell?


>>> a=("Check")*3

>>> a



a)

(‘Check’,’Check’,’Check’)

b)

* Operator not valid for tuples

c)

(‘CheckCheckCheck’)

d)

Syntax error

51.

Which are arithmetic operators?

a)

+

b)

-

c)

>

d)

<

52.

Which of the following cannot be a variable?

a)

_init_

b)

in

c)

it

d)

on

53.

Which one of these is floor division?

a)

//

b)

/

c)

%

d)

None of the above

54.

Python is a general purpose programming language created by

a)

Dennis M. Ritchie

b)

Guido Van Rossum

c)

James Gosling

d)

Bjarne Stroustrup

55.

Expand IDLE

a)

Internal Development Learning Environment

b)

Integrated Development Learning Enforcement

c)

Interactive Development Learning Environment

d)

Integrated Development Learning Environment

56.

Example of valid identifiers

a)

12Name

b)

name$

c)

total-mark

d)

total_marks

57.

A Relational operator is also called as ___________

a)

Arithmetic operator

b)

Logical operator

c)

Assignment operator

d)

Comparative operator

58.

"and, or and not" are ___________________

a)

Arithmetic operator

b)

Logical operators

c)

Assignment operator

d)

Comparative operator

59.

__________are special words that are used by Python interpreter to recognize the

structure of program.

a)

Tokens

b)

Identifiers

c)

Keywords

d)

Operators

60.

Choose the INVALID identifiers from the following

a)

NUmbEr1

b)

1NUMBer

c)

A_B

d)

A&B

61.

________ are data items that have a fixed value

a)

Tokens

b)

Literals

c)

Keyword

d)

Operators

62.

Examples of String Literals

a)

"ABC1273"

b)

nfjdlsj@@$

c)

12638

d)

'7e920938'

63.

Choose the keyword from the following

a)

IF

b)

Else

c)

iF

d)

else

64.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

65.

Python is a high level language

a)

Yes

b)

No

66.

Onlinegdp is used as a :

a)

compiler

b)

text editor

c)

interpreter

d)

debugger

67.

In Python , variable name must start with a letter or the underscore character

a)

Yes

b)

No

68.

Commands written in Python are very complex

a)

yes

b)

no

69.

Following is an example of a built-in function in Python:

a)

sum()

b)

sub()

c)

float()

70.

the data type string can only store

a)

text

b)

text and numbers

c)

numbers

71.

print (18 % 6) gives the following value:

a)

3

b)

2

c)

0

d)

1

72.

A function in Python always return a value:

a)

Yes

b)

No

c)

6

d)

4

73.

python file has the following extension:

a)

python

b)

pycharm

c)

py

d)

py1

74.

# is used to :

a)

enter text to a program

b)

enter a number to a program

c)

enter comments to a program

75.

What is the name of the programming language we are learning?

a)

python

b)

scratch

c)

scribble

d)

pie thin

76.

What symbol do you use to make a comment in Python?

a)

@

b)

:

c)

?

d)

#

77.

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

78.

Python is an example of a....

a)

language written in java script

b)

Visual-based programming language

c)

Object orientated programming language

d)

Text-based programming language

79.

What extension must you add to the end of a file when saving?

a)

.xlsx

b)

.py

c)

.docx

d)

.pptx

80.

What does the print function do in python?

a)

It loops the code.

b)

It's a variable.

c)

It can input data.

d)

It displays something like a string or integer

81.

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

a)

True

b)

False

82.

What is the correct definition for a VARIABLE?

a)

a changeable value, such as a score in a computer game.

b)

a value that cannot be changed

83.

What are the different data types in Python?

a)

The different data types in Python are: int, float, complex, str, list, tuple, set, dict, bool, and NoneType.

b)

integer, decimal, character, list, boolean

c)

number, text, array, dictionary, boolean

d)

int, float, string, array, boolean

84.

What is the syntax for an if statement in Python?

a)

The syntax for an if statement in Python is: if {condition}

b)

The syntax for an if statement in Python is: if condition: # code block

c)

The syntax for an if statement in Python is: if condition then

d)

The syntax for an if statement in Python is: if (condition)

85.

How do you write a for loop in Python?

a)

for i in range(1, 10, 2):

b)

for x in range(5, 10):

c)

for item in iterable_object:

d)

for i in range(10):

86.

What is the purpose of a function in Python?

a)

The purpose of a function in Python is to encapsulate a set of instructions that can be reused and called multiple times within a program.

b)

The purpose of a function in Python is to print a specific value to the console

c)

The purpose of a function in Python is to stop the execution of the program

d)

The purpose of a function in Python is to create a new variable

87.

What is a list in Python?

a)

A list in Python is a type of loop

b)

A list in Python is a type of function

c)

A list in Python is a collection of items that are ordered and changeable. It allows duplicate elements and can contain different data types.

d)

A list in Python is a type of snake

88.

What is a tuple in Python?

a)

A tuple in Python is a collection of unordered and mutable elements, represented by square brackets.

b)

A tuple in Python is a data type used for storing multiple values like a list, represented by curly braces.

c)

A tuple in Python is a collection of ordered and immutable elements, represented by parentheses.

d)

A tuple in Python is a single value that cannot be changed, represented by angle brackets.

89.

Explain the concept of a dictionary in Python.

a)

A dictionary in Python is a collection of key-value pairs. It is unordered, changeable, and does not allow duplicate keys. Each key is unique and is used to access its corresponding value.

b)

A dictionary in Python is a collection of key-value pairs, but the keys can be duplicated.

c)

A dictionary in Python is a collection of values without keys.

d)

A dictionary in Python is a collection of ordered pairs.

90.

What is the difference between a while loop and a for loop in Python?

a)

While loop is for beginners, for loop is for advanced programmers

b)

The main difference is in their usage and the way they control the flow of the program.

c)

While loop is used for odd numbers, for loop is used for even numbers

d)

The difference is in the color of the text they use

91.

What is the purpose of using 'elif' in Python?

a)

The 'elif' statement is used to check for multiple conditions after the 'if' statement and before the 'else' statement.

b)

The 'elif' statement is used to end the program if the 'if' condition is not met.

c)

The 'elif' statement is used to create a new variable in Python.

d)

The 'elif' statement is used to print a specific value to the console.

92.

What is the purpose of using 'break' in a loop in Python?

a)

The 'break' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop.

b)

The 'break' statement is used to skip the current iteration and continue with the next iteration of the loop.

c)

The 'break' statement is used to print a specific value to the console.

d)

The 'break' statement is used to create a new variable in Python.

93.

What is the purpose of using 'pass' in Python?

a)

The 'pass' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop.

b)

The 'pass' statement is used to skip the current iteration and continue with the next iteration of the loop.

c)

The 'pass' statement is used to create a new variable in Python.

d)

The 'pass' statement is used to do nothing and acts as a placeholder.

94.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
95.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
96.
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
97.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
98.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
99.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
100.
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
101.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
102.
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
103.

Which is the Python logo?

a)
b)
c)
d)
104.

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

105.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

106.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

107.

Operators used in python:


divide, multiply, add, subtract

a)

/, *, +, -

b)

div, mul, +, -

c)

\, x, +, -

d)

~, *, +, -

108.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
109.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
110.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
111.
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
112.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
113.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
114.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
115.
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
116.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
117.
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
118.

Which is the Python logo?

a)
b)
c)
d)
119.

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

120.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

121.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

122.

Operators used in python:


divide, multiply, add, subtract

a)

/, *, +, -

b)

div, mul, +, -

c)

\, x, +, -

d)

~, *, +, -

123.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
124.

Write the output of the following code:

x=2

x=5

x=x+x

print(x)

a)

7

b)

10

c)

4

d)

Error

125.

Write the output of the following code :

x=2

y=3

x+y+5

print(x+y)

a)

8

b)

6

c)

10

d)

5

126.

What is a keyword?

a)

Reserved Word

b)

Predefined Word

c)

Keywords are part of the syntax and they cannot be used as an identifier.

d)

All of them

127.

Which statement will display square of number (n)

a)

print(n * n)

b)

print(math.pow(n,2)) # math module is already imported

c)

All of the above

d)

Only First

128.

Select the reserved keyword in python-

a)

else

b)

raise

c)

import

d)

All of them

129.

What will be the output of this string operation s[2:5] , if s="hello world" -

a)

lo

b)

llo

c)

llow

d)

ell

130.

Which of the following character is used to give single-line comments in Python?

a)

//

b)

#

c)

!

d)

/*

131.

What will be the output?

name = 'Python'

print (type(name))

a)

char

b)

'Python'

c)

str

d)

Error

132.

What will be the output?

d = 10 < 11

print (d)

a)

10

b)

11

c)

True

d)

False

133.

Identify the arithmetic operator which is used to calculate exponential.

a)

*

b)

%

c)

!

d)

**

134.

What will be the output?

str1 = "Deep Learning"

print (len(str1))

a)

11

b)

12

c)

13

d)

Out of Range Error

135.

What will be the output?

a = 25

b = 4

print (a%b)

a)

1

b)

6

c)

6.2

d)

1.5

136.

What will be the output ?

print (type(5 // 2))

a)

int

b)

float

c)

2

d)

2.5

137.
What is Python really?
a)
Python is an interpreted language.
b)
visual basic
c)
a snake 
d)
a form of font for writing 
138.
what are the advantages of python?
a)
free and open source 
b)
can do the work for you 
c)
easy 
139.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
140.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

141.

1. He is a Dutch Programmer known as the creator of Python?

a)

a. Rasmus Lerdorf

b)

b. James Gosling

c)

c. Guido van Rossum

d)

d. Niklaus Wirth

142.

2. What does IDE mean?

a)

a. Internet Detection Entertainment

b)

b. Integrated Development Environment

c)

c. Instantaneous Differentiation Equipment

d)

d. Intermediate Development Element

143.

3. Which of the following is not an IDE for Python?

a)

a. XML

b)

b. Pycharm

c)

c. Visual Studio Code

d)

d. Thonny

144.

5. It is the process of joining two or more strings.

a)

a. Addition

b)

b. Concatenation

c)

c. Integration

d)

d. Differentiation

145.

6. What does % math operator do?

a)

a. To get the remainder of the two numbers.

b)

b. To get the square root of two numbers.

c)

c. To get the percentage from those two numbers.

d)

d. To get the quotient of the two numbers.

146.

7. What does == mean?

a)

a. Assignment operator

b)

b. Answer operator

c)

c. Equality operator

d)

d. Mathematical operator

147.

8. What symbol is used to denote "not equal"?

a)

a. *=

b)

b. @=

c)

c. ?=

d)

d. !=

148.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99