wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
2.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
3.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
4.

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

5.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
6.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
7.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
8.

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

print (people[4])

what would this result be?

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

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
10.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

11.

5.This symbol is used to print more than one item on a single line.

a)

semicolon (;)

b)

dollar ($)

c)

comma (,)

d)

colon(:)

12.

7.Which of the following is not a keyword in python?

a)

break

b)

while

c)

continue

d)

operator

13.

8.Which operator is also called comparative operator?

a)

arithmetic operator

b)

relational operator

c)

logical operator

d)

assignment operator

14.

9.Which of the following is not logical operator?

a)

and

b)

or

c)

assignment

d)

not

15.

What is missing from this program – print(hello)?

a)

‘‘ ’’

b)

::

c)

??

d)

*** ***

16.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
17.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
18.

It is possible to execute both the statements under if and else at the same time.

a)

TRUE

b)

FALSE

19.

There can be an else statement without an if statement

a)

FALSE

b)

TRUE

20.
A _____________ expression is an expression that is either true or false. 
a)
boolean
b)
truth
c)
variable
d)
conditional
21.

What is does this code display?

a)

You are in primary school.

b)

You are in secondary school.

c)

You are not in school.

d)

Nothing.

22.

Which logic operator is used when only one condition has to be true?

a)

and

b)

or

c)

not

23.

What does the 'not' logic operator do?

a)

Nothing.

b)

Changes an if statement so that the condition needs to be true.

c)

Changes an if statement so that the condition needs to be false.

d)

Changes a value.

24.

What is the difference between complex and simple conditions?

a)

Complex conditions have more than one condition.

b)

Simple conditions have more than one condition.

c)

Complex conditions use the 'not' operator.

d)

Only simple conditions can use logic operators.

25.

What will this code output?

a)

Fizz

b)

Buzz

c)

True

d)

False

26.

In input/process/output, what is process?

a)

The whole program.

b)

What information comes out of the program.

c)

What the user types in to the program.

d)

How the program modifies the information it has received in order to produce the output.

27.

What function converts a string to an integer?

a)

float()

b)

str()

c)

int()

d)

bool()

28.

What is the type of data in the below code?

print(type(90+1j))

a)

Float

b)

String

c)

Complex Numbers

d)

None of the above

29.

Which of the following enclose the input parameters or arguments of a function?

a)

Curly braces

b)

round braces

c)

Square Braces

d)

None of the above

30.

Which of the following keywords marks the beginning of the function block?

a)

Define

b)

key

c)

def

d)

Fun

31.

What is the output for the below code snippet?


def fun(message,num=3):

print(message*num)

fun('welcome')

a)

Error

b)

Welcome

c)

welcomewelcomewelcome

d)

None of the above

32.

What is the output for the below code snippet?


def func():

num = 3

print(num)


func()

a)

num

b)

func

c)

1

d)

3

33.

What does the min() function do?

a)

Gives the minimum function

b)

Gives the maximum function

c)

Gives the minimum and the maximum function

d)

None of the above

34.

What is a list?

a)

A set of integers

b)

A set of strings

c)

A mixed bag of datatypes

d)

None of the above

35.

Which of the following is the correct option for list creation?

a)

List = [""1,""1,""3]

b)

List = (1,2,3,4)

c)

List = [ 1,2,3,4]

d)

List = [1 2 3 4]

36.

Which of the following is true for a tuple?

a)

Tup = 1,2,3

b)

Tup = (""1,"2)

c)

Tup = (1,2,3,4)

d)

None of the above

37.

Which of the following is not true for strings?

a)

String = [1,2,3,4]

b)

String = "hello"

c)

String = 'hello'

d)

String = ''' Hello '''

38.

Python functions can return a value?

a)

True

b)

False

39.

Is python list mutable?

a)

True

b)

False

40.

Choose the immutable data types

a)

Dictionary

b)

Tuple

c)

List

d)

String

41.

Which of the following is a mutable data type ?

a)

Dictionary

b)

List

c)

String

d)

int

42.

Name the function used for finding the data type of a variable.

(a)  

43.

15%3

(a)  

44.

Choose the operator that calculates the quotient

a)

&

b)

**

c)

%

d)

/

45.

Which operator has the highest precedence ?

a)

%

b)

//

c)

/

d)

**

46.

False and True

a)

True

b)

False

47.

Which of the following is a logical operator?

a)

not

b)

And

c)

or

d)

Or

48.

a/=b is same as ?

a)

b=a/b

b)

a=b/a

c)

a=a/b

d)

b=b/a

49.

Name the type of operator >=

a)

Logical

b)

Relational

c)

Assignment

d)

Arithmetic

50.

_______ error occurs when the rules of the programming language is violated.

a)

Runtime

b)

Syntax

c)

Logical

51.

Which of the following gives a syntax error in Python?

a)

100=a

b)

a=102

c)

print 7+3

d)

Print 7

52.

Is Python a Case Sensitive Language?

a)

Yes

b)

No

c)

May not be

d)

None of the above

53.

What is answer of this expression, 22 % 3 is?

a)

7

b)

1

c)

0

d)

5

54.

Mathematical operations can be performed on a string.

a)

True

b)

False

c)

May not be

d)

None of the above

55.

What is the output when following statement is executed ?>>>"a"+"bc"

a)

a

b)

bc

c)

ac

d)

abc

56.

What is the output when following code is executed ?

>>> str1 = 'hello'

>>> str2 = ','

>>> str3 = 'world'

>>> str1[-1:]

a)

olleh

b)

hello

c)

h

d)

o

57.

What is the output of the following code ?

>>>example = "snow world"

>>>example[3] = 's'

>>>print example

a)

snow

b)

snow world

c)

error

d)

snos world

58.

Which of the following commands will create a list?

a) list1 = list()

b) list1 = [].

c) list1 = list([1, 2, 3])

d) all of the mentioned

a)

list1 = list()

b)

list1 = [].

c)

list1 = list([1, 2, 3])

d)

all of the mentioned

59.

Suppose list1 is [3, 5, 25, 1, 3], what is min(list1) ?

a)

3

b)

5

c)

1

d)

25

60.

Suppose list1 is [1, 5, 9], what is sum(list1) ?

a)

1

b)

9

c)

15

d)

none

61.

What will be the output?

names1 = ['Amir', 'Bala', 'Chales']

if 'amir' in names1:

print(1)

else: print(2)

a)

None

b)

1

c)

2

d)

error

62.

1. Which of the following statements create a dictionary?

a)

d = {}

b)

d = {“john”:40, “peter”:45}

c)

d = {40:”john”, 45:”peter”}

d)

All of the mentioned