wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming EndTerm

Total questions: 61

Worksheet time: 34mins

Name
Class
Date
1.

Which of the following are all basic parts of a desktop computer?

a)

Computer case, monitor, printer

b)

Keyboard, headphones, monitor

c)

Mouse, speakers, computer case

d)

Keyboard, mouse, computer case

2.

The _____________ works with a video card to display images and text.

a)

computer case

b)

keyboard

c)

monitor

d)

printer

3.

___________________ are devices that plug into the extra ports on your computer.

a)

Peripherals

b)

Servers

c)

Software

d)

Laptops

4.

Python is an example of a:

a)

Text-based programming language

b)

Visual-based programming language

c)

Block-based programming language

d)

Language written in JavaScript

5.

A data type consisting of numbers letters and symbols:

a)

String

b)

Integer

c)

Float

d)

Boolean

6.

What does term ‘debug’ mean:

a)

looking at the code

b)

a set of instructions

c)

Identify errors and fix them

d)

Making a calculation

7.

To repeat until a particular condition is true use:

a)

While loop

b)

For loop

c)

If loop

d)

Indentation

8.

What does an if statement do?

a)

Close the program

b)

Ask a question

c)

Make a decision

d)

Write a comment

9.

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

10.

_____ data type contain integer values with no decimal such as 1, 200, 999 etc.

a)

int

b)

float

c)

char

d)

String

11.

Which if the values below is an integer data type?

a)

1

b)

1.0

c)

1/2

d)

"1"

12.

Which value is a Boolean?

a)

64

b)

"cat"

c)

True

d)

0.5

13.

What is a variable?

a)

A storage location of memory which can change

b)

A random area to store things in.

c)

Something that changes

d)

Something that can only store numbers

14.

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

15.
Which of the following is a correctly-formatted comment?
a)
#Comment
b)
&Comment
c)
""Comment""
d)
!Comment
16.

What is the output of the following list operation

aList = [10, 20, 30, 40, 50, 60, 70, 80]

print(aList[2:5])

print(aList[:4])

print(aList[3:])

a)

[20, 30, 40, 50]

[10, 20, 30, 40]

[30, 40, 50, 60, 70, 80]

b)

[30, 40, 50]

[10, 20, 30, 40]

[40, 50, 60, 70, 80]

c)

None of these

17.

Suppose list1 is [1, 3, 2], What is list1 * 2 ?

a)

[2, 6, 4].

b)

[1, 3, 2, 1, 3]

c)

[1, 3, 2, 1, 3, 2]

d)

[1, 3, 2, 3, 2, 1]

18.

The code snippet above outputs

a)

error

b)

None

c)

NaN

d)

-1

19.

The output of the code above is

a)

[101, 102, 103, 104]

b)

[3.6, 3.7, 3.8, 4]

20.

Which of the following code deletes the key 103 and its value

a)

del grades[103]

b)

grades.pop(103)

c)

del grades["103"]

d)

grades.pop("103")

e)
21.

What will be the output of the following Python code?

nums = set([1,1,2,3,3,3,4,4])

print(len(nums))

a)

7

b)

Error, invalid syntax for formation of set

c)

4

d)

8

22.

Which of the following statements is used to create an empty set?

a)

{ }

b)

set()

c)

[ ]

d)

( )

23.

What will be the output of the following Python code?

>>> a={3,4,5}

>>> a.update([1,2,3])

>>> a

a)

Error, no method called update for set data type

b)

{1, 2, 3, 4, 5}

c)

Error, list can’t be added to set

d)

Error, duplicate item present in list

24.

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a

>>> b.remove(3)

>>> a

a)

{1,2,3}

b)

Error, copying of sets isn’t allowed

c)

{1,2}

d)

Error, invalid syntax for remove

25.

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a.copy()

>>> b.add(4)

>>> a

a)

{1,2,3}

b)

Error, invalid syntax for add

c)

{1,2,3,4}

d)

Error, copying of sets isn’t allowed

26.

What will be the output of the following Python code?

s=set()

type(s)

a)

<’set’>

b)

<class ‘set’>

c)

set

d)

class set

27.

What’s the main difference between Python lists and tuples?

a)

Lists can hold any data type and tuples can only contain int and str objects.

b)

Lists are immutable and tuples are mutable.

c)

Lists are mutable and tuples are immutable.

d)

Lists are faster and tuples are slower.

Check Your Answer »

28.

Write the Python code that prints out Captain Kirk’s email address from the employee dictionary below:


employee = { "id": 1701, "name": "James T Kirk",

"email": "jtkirk@starfleet.com","position": "captain"}




(a)  

29.

What would this out put? print(users[0][0])

a)

smith

b)

ben

c)

sam

d)

james

30.

A Python dictionary stores ...

a)

value - key pairs

b)

key - value pairs

31.

A dictionary is an example of a sequence ...

a)

True

b)

False

32.

Which of the following create an empty dictionary (D)?

a)

D = dict()

b)

D = ()

c)

D = []

d)

D = {}

33.
Which symbol surrounds a dictionary?
a)
{
b)
(
c)
[
d)
:
34.
is this code correct?
quiz = ("Do you help out at home? ":"yes"      }
a)
No
b)
Yes
c)
Both
35.

File extension of Python program is ______

a)

.py

b)

.p

c)

.pyx

d)

.pyy

36.

List index begins with _________.

a)

0

b)

1

c)

-1

d)

-2

37.

_________________is an anonymous function.

a)

User Defined

b)

Default

c)

Lambda

d)

Reserved

38.

What will be the anser for this code?

a)

120

b)

650

c)

225

d)

400

39.

_______is used as a dummy place holder whenever a syntactical requirement of a certain programming element is to be fulfilled without assigning any operation

a)

Pass

b)

Break

c)

While

d)

Goto

40.

What is the default return value for a function that does not return a value explicitly?

a)

None

b)

int

c)

double

d)

null

41.

Which of the following items are present in the function header?

a)

Function name only

b)

Both function name and parameter list

c)

parameter list only

d)

Return value

42.

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

a)

Func

b)

define

c)

def

d)

function

43.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
44.
What will print?
a)
1 2
b)
1
c)
3
d)
5
45.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

46.

Leo wants to create a subroutine that will roll a dice. Which syntax is correct?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

47.
How do you correctly call this function
a)
def(1)
b)
x=square( )
c)
defSquare(4)
d)
x=square(5)
48.
What is Python really?
a)
Python is an interpreted language.
b)
visual basic
c)
a snake 
d)
a form of font for writing 
49.
what are the advantages of python?
a)
free and open source 
b)
can do the work for you 
c)
easy 
50.

This program will produce

a)

a random number between 10 and 100 (including 10 but not 100) always in increments of 10

b)

a random number between 10 and 100 (including 10 and 100) always in increments of 10

c)

10 random numbers between 10 and 100 (including 10 and 100)

d)

10 random numbers between 10 and 100 (including 10 and not 100)

51.

Which operator is used in python to import all modules from packages?

a)

. operator

b)

* operator

c)

-> symbol

d)

, operator

52.

What is the extension of python library modules?

a)

.mod

b)

.lib

c)

.code

d)

.py

53.

A _______________ allows you to logically organize your Python code.

a)

packages

b)

module

c)

method

d)

class

54.

Grouping related code into a module makes the ___________________ and use.

a)

access code

b)

remove code

c)

access to understand

d)

code easier to understand

55.

Module can contain ____________ and ____________ .

a)

functions, variables

b)

class,method

c)

object,syntax

d)

expression,file

56.

Re-naming the module as _______________ keyword.

a)

as

b)

re

c)

ar

d)

rn

57.

Bundle multiple modules together to form a

________________ .

a)

package

b)

module

c)

class

d)

method

58.

Name the Python Library modules which need to be imported to invoke the following function:  fabs(),ceil()

a)

 random

b)

statistics

c)

math

d)

built-in

59.

Which one is a VALID statement 

a)

from math,random import *

b)

import math.sqrt

c)

import random as r

d)

from math import * as m

60.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
61.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list