wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python El Grand Revision!

Total questions: 47

Worksheet time: 49mins

Name
Class
Date
1.

We use "git (a)   " command to upload the content of local repository to the remote repository

2.

We use "git (a)   " command to stage changes by adding new or modified files to the staging area

3.

In order to update the content of the local repository with that from the remote repository, we use:

a)

git push

b)

git commit

c)

git pull

d)

git add

4.

We want to build a program to accept a number, check if it's divisible by 7 and print suitable message. What would the main condition have to be?

a)

if num %7 == 0:

b)

if num %7 == 7:

c)

if num ** 7:

d)

if 7 == num:

5.

To generate even numbers between 19 and 34 (inclusive) we would call:

a)

range(19,34)

b)

range(19,34,2)

c)

range(19,35,2)

d)

range(18,35,2)

6.

Which of the following is NOT a valid way of importing functions/modules?

a)

from tui import *

b)

import * from tui

c)

import func

d)

from tui import func

7.

Let x = ("pear", "apple", "orange", "raspberry")

What does print(x[-2]) achieve?

a)

"orange" is printed on the console

b)

Error is generated

c)

"x[-2]" is printed on the console

d)

"apple" is printed on the console

8.

Let x = {"ham", "cheese", "jam", "bread", "eggs", "brain", "jam", "eggs"}

What is len(x) ?

a)

8

b)

6

c)

underfined/error

d)

none of the other options

9.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll():

b)

def diceroll()

c)

def dice_roll():

d)

def diceroll[]:

10.
What data type is this?
quiz = {"Do you help out at home? ":"yes",        
"Do you beleive in Santa? ":"yes"
}
a)
list
b)
string
c)
dictionart
d)
dictionary
11.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

12.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

13.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

14.

Which is a correctly declared tuple?

a)

a = ("orange", "yellow", "red")

b)

a = "orange", "yellow", "red"

c)

a = ["orange", "yellow", "red"]

d)

a = "orangeyellowred"

15.

Which line of code will give you an error? b = (4, 5, 6, 7, 8)

a)

b[2]

b)

b[0] = 1

c)

b[:3]

d)

b[-2]

16.

How would you refer to 3 in the following tuple? c = ((7,5),(5,8),(0,-1),(4,3))

a)

c[0][0]

b)

c(3)

c)

c[8]

d)

c[3][1]

17.

What will be the output of the following Python code?

x = {4,7,8,8,9}

print(x)

a)

{4, 7, 9}

b)

{8, 9, 4, 7}

c)

{4, 7, 8, 8, 9}

d)

Error

18.

Which of the following statements is true for objects of Python’s set type:

a)

The order of elements in a set is significant

b)

A given element can’t appear in a set more than once

c)

Sets are of fixed length

d)

A set may contain elements that are mutable

19.

Consider this dictionary:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What is the result of this statement:


d['bar':'baz']

a)

It raises an exception

b)

(200, 300)

c)

200 300

d)

[200, 300]

20.

What would be the output of the following code snippet?


a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}


for key in a_dict:

print(key)

a)

'blue'

'apple'

'dog'

b)

color

fruit

pet

c)

blue

apple

dog

d)

'color'

'fruit'

'pet'

21.

Which of the following will give you an error?

Suppose dict1={"a":1,"b":2,"c":3}

a)

print(len(dict1))

b)

print(dict1.get("b"))

c)

dict1["a"]=5

d)

None of these

22.

Which of these data types can be used as Keys in a Dictionary? (pick all that apply)

a)

string

b)

set

c)

boolean

d)

tuple

e)

list

23.

Which code should we use to display our graphs?

a)

plt.display()

b)

plt.graph()

c)

plt.show()

d)

plt.chart()

24.

Which library is the most used visulization library in python?

a)

Visual

b)

Matlibplot

c)

Matplotlib

d)

matlab

25.

Which function of matplotlib can be used to create a line chart?

a)

Line

b)

Plot

c)

Graph

d)

Bar

26.

Which graph should be used If we want to find patterns in data?

a)

bar

b)

histogram

c)

scatterplots

d)

basemap

27.

np.arange(2,8,1) ----> what output will be produced?

a)

2,3,4,5,6,7,8

b)

2,3,4,5,6,7,8,9

c)

2,3,4,5,6,7

d)

2,4,6,8

28.

Which one is the correct syntax to import the library for the data visualisation?

a)

import matplotlib

b)

import matplotlib as pyplot

c)

import pyplot

d)

import matplotlib.pyplot as plt

29.

What is the most suitable graph to display the distribution of commission earned by employees?  This visualisation shows commission as categories and the number of people in each category.

a)

bar chart

b)

scatter plot

c)

line graph

d)

histogram

30.

What would be a suitable visualisation for showing changes in revenue of a company over a period of 24 months?

a)

scatter diagram

b)

pie chart

c)

histogram

d)

line graph

31.

What would be a suitable visualisation to present student's country of birth, considering a population of a single Computing group?

a)

bar chart

b)

pie chart

c)

scatter diagram

d)

tree map

32.

Mode in the following program to open file for writing in a mode where new data will be added at the end of old data

file =open("poem.txt","__")

a)

r

b)

w

c)

a

d)

r+

33.

What will be the ouput -

f=open('abc.txt','w')

x=f.read()

f.close()

print(x)

a)

Error(not readable)

b)

Error(not writable)

c)

It will read all the data of the file.

d)

none

34.

What will be the output-

f=open('abc.txt','a')

text="xyz"

f.write(text)

f.close()

a)

Writing into the file without erasing old content

b)

Writing into the file by erasing old content

c)

reading from the file without erasing old content

d)

reading from the file by erasing old content

35.

The readlines() method returns

a)

a. str

b)

b. a list of lines

c)

c. a list of single characters

d)

d. a list of integers

36.

What will be the output of the following Python code?

a)

True

b)

False

c)

None

d)

error

37.

What does CSV stand for?

a)

Cursor Separated Variables

b)

Comma Separated Values

c)

Cursor Separated Values

d)

Cursor Separated Version

38.

When iterating over an object returned from csv.reader(), what is returned with each iteration?


For example, given the following code block that assumes csv_reader is an object returned from csv.reader(), what would be printed to the console with each iteration?


for item in csv_reader:

print(item)

a)

The column data as a list

b)

The individual value data that is separated by the delimiter

c)

The full line of the file as a string

d)

The row data as a list

39.

write statement to use the required module for working with comma separated values (csv) files.

(a)  

40.

What is a class (in python)?

a)

A user-defined prototype for an object that defines a set of attributes that characterize any object of this. The attributes are data members and methods, accessed via dot notation.

b)

A special kind of function that is defined in a class definition.

c)

The assignment of more than one behavior to a particular function. The operation performed varies by the types of objects or arguments involved.

d)

the system of ordering a society in which people are divided into sets based on perceived social or economic status.

41.

What is an instance in python?

a)

A special kind of function that is defined in a class definition.

b)

The creation of an instance of a class.

c)

An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.

d)

A moment in time

42.

What is a method in python?

a)

a way of doing something

b)

a special kind of function that is defined in a class definition

c)

the creation of an instance of a class

d)

orderliness of thought or behavior; systematic planning or action

43.

What is an object in python?

a)

A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.

b)

A special kind of function that is defined in a class definition.

c)

The assignment of more than one function to a particular operator.

d)

An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.

44.
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
45.

What will be printed?

a)

nothing

b)

7

c)

z

d)

12

46.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
47.

How confident are you about the upcoming AE1: TCA?

a)

I am going to smash it!

b)

I will do well

c)

I will be okay, hopefully

d)

Don't have a good feeling

e)

It will be a disaster :(