wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

KIT PYTHON

Total questions: 90

Worksheet time: 1hrs 13mins

Name
Class
Date
1.

Who developed Python Programming Language?

a)

a) Wick van Rossum

b)

b) Rasmus Lerdorf

c)

c) Guido van Rossum

d)

d) Niene Stom

2.

Which of the following is the correct extension of the Python file?

a)

a) .python

b)

b) .pl

c)

c) .py

d)

d) .p

3.

What will be the value of the following Python expression?

4 + 3 % 5

a)

a) 7

b)

b) 2

c)

c) 4

d)

d) 1

4.

Which of the following is used to define a block of code in Python language?

a)

a) Indentation

b)

b) Key

c)

c) Brackets

d)

d) All of the mentioned

5.

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

a)

a) //

b)

b) #

c)

c) !

d)

d) /*

6.

What is the order of precedence in python?

a)

a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

b)

b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction

c)

c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition

d)

d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

7.

Which of the following functions is a built-in function in python?

a)

a) factorial()

b)

b) print()

c)

c) seed()

d)

d) sqrt()

8.

Which of the following is not a core data type in Python programming?

a)

a) Tuples

b)

b) Lists

c)

c) Class

d)

d) Dictionary

9.

To add a new element to a list we use which Python command?

a)

a) list1.addEnd(5)

b)

b) list1.addLast(5)

c)

c) list1.append(5)

d)

d) list1.add(5)

10.

What will be the output of the following Python statement?

>>>"abcd"[2:]

a)

a) a

b)

b) ab

c)

c) cd

d)

d) dc

11.

What will be the output of the following Python code?

>>> str1 = 'hello'

>>> str2 = ','

>>> str3 = 'world'

>>> str1[-1:]

a)

a) olleh

b)

b) hello

c)

c) h

d)

d) o

12.

What will be the output of the following Python code?

>>>str1="helloworld"

>>>str1[::-1]

a)

a) dlrowolleh

b)

b) hello

c)

c) world

d)

d) helloworld

13.

What will be the output of the “hello” +1+2+3?

a)

a) hello123

b)

b) hello

c)

c) Error

d)

d) hello6

14.

Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?

a)

a) 5

b)

b) 4

c)

c) None

d)

d) Error

15.

Suppose list1 is [2445,133,12454,123], what is max(list1)?

a)

a) 2445

b)

b) 133

c)

c) 12454

d)

d) 123

16.

Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?

a)

a) [2, 33, 222, 14]

b)

b) Error

c)

c) 25

d)

d) [25, 14, 222, 33, 2]

17.

If a=(1,2,3,4), a[1:-1] is _________

a)

a) Error, tuple slicing doesn’t exist

b)

b) [2,3]

c)

c) (2,3,4)

d)

d) (2,3)

18.

Which of the following statements create a dictionary?

a)

a) d = {}

b)

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

c)

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

d)

d) All of the mentioned

19.

What will be the output of the following Python code snippet?

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

d["john"]

a)

a) 40

b)

b) 45

c)

c) “john”

d)

d) “peter”

20.

What will be the output of the following Python code?

a={1:"A",2:"B",3:"C"}

b={4:"D",5:"E"}

a.update(b)

print(a)

a)

a) {1: ‘A’, 2: ‘B’, 3: ‘C’}

b)

b) Method update() doesn’t exist for dictionaries

c)

c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}

d)

d) {4: ‘D’, 5: ‘E’}

21.

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

22.

Is the following piece of code valid?


>>> a=(1,2,3,4)

>>> del a

a)

No because tuple is immutable

b)

Yes, the entire tuple is deleted

c)

No, invalid syntax for del method

d)

Yes, first element in the tuple is deleted

23.

What type of data is: a=[(1,1),(2,4),(3,9)]?

a)

Array of tuples

b)

List of tuples

c)

Tuples of lists

d)

Invalid type

24.

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

25.

Result of the program above is

a)

('1', '2', '3', '4', '5')

b)

(1, 2, 3, 4, 5)

c)

12345

d)

"12345"

26.

Suppose you have the following tuple definition:


t = ('foo', 'bar', 'baz')


Which of the following statements replaces the second element ('bar') with the string 'qux':

a)

t[1] = 'qux'

b)

t(1) = 'qux'

c)

t[1:1] = 'qux'

d)

error

27.

If list=[17,23,41,10] then list.append(32) will result

a)

[32,17,23,41,10]

b)

[17,23,41,10,32]

c)

[10,17,23,32,41]

d)

[41,32,23,17,10]

28.

Suppose list=[12,3,22,"mago","hello"], what is list[-6]

a)

Error

b)

None

c)

mango

d)

12

29.

L_names=['Harsh','Amit','Sahil','Viresh']

min(L_names)

a)

'Harsh'

b)

'Amit'

c)

'Viresh'

d)

None of the above

30.

L_names=['Harsh','Amit','Sahil','Viresh']

L_names.pop()

a)

'Harsh'

b)

'Amit'

c)

'Viresh'

d)

None of the above

31.

If L1=[2,4,8,16], L2=[32,64] what is L1+L2

a)

[2,4,8,16,32,64]

b)

[2,4,8,16][32,64]

c)

[2,4,8,16],[32,64]

d)

None of the above

32.

L=[2,4,8,16,32,64] what is L[:2]

a)

[2,4]

b)

[2,4,8]

c)

2,4

d)

None of the above

33.

T=((1,2,3),(3,4))

what is T[1][1]

a)

4

b)

3

c)

2

d)

1

34.

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]

35.

To remove string “hello” from list1, we use which command?

a)

list1.remove(“hello”)

b)

list1.remove(hello)

c)

list.remove(“hello”)

d)

list.remove(hello)

36.

Suppose a tuple T is declared as T=(20,36,34,49), which of the following is incorrect?

a)

print(T[3])

b)

T[3] = 49

c)

print(min(T))

d)

print(T.count(20))

37.

What is the output of the code?

a = (33, 55)

a.append(22)

print(a)

a)

33 55 22

b)

33

55

22

c)

33, 55, 22

d)

Error

38.

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

39.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

40.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

41.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

42.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

43.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

44.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

45.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

46.

What is the output?

a)

level 3

b)

level 3

level 1

c)

level 3

level 1

NIL

d)

level 3

level 2

level 1

NIL

47.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

48.

Given the nested if-else below, what will be the value x when the code is executed successfully.

a)

0

b)

4

c)

2

d)

3

49.

Given the nested if-else structure below, what will be the value of x after code execution completes.

a)

2

b)

0

c)

3

d)

4

50.

What is the output of the following if statement?

a)

False

b)

True

51.
Which is the correct syntax?
a)
has_dog = true
b)
has_dog = True
c)
has_dog = Treu
d)
HAS_DOG = tRue
52.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
53.

What is the result of the code:

team = Cowboys

if team = Cowboys:

print(Dallas is #1)

a)

Error

b)

Cowboys

c)

Team

d)

Dallas is #1

54.
What best defines an IF statement in python?
a)
Is an embedded string with a variable
b)
An IF statement checks to see if a statement is true or false and then does one of two things depending on the result.
55.
I am 71 years old! What will the output be?: IF you are 70 or older, say “You are aged to perfection!” ELIF you are exactly 50, say “Wow, you are half a century old!” ELSE say “You are a spring chicken!”
a)
“You are aged to perfection!”
b)
"Wow, you are half a century old!"
c)
"You are a spring chicken!"
56.
I am 18 years old! What will the output be?: IF you are 70 or older, say “You are aged to perfection!” ELIF you are exactly 50, say “Wow, you are half a century old!” ELSE say “You are a spring chicken!”
a)
"You are aged to perfection"
b)
"Wow, you are half a century old!"
c)
"You are spring chicken!"
57.

Which of the following usees FIFO method

a)

Queue

b)

stack

c)

linklist

d)

binary tree

58.

This form of access is used to add and remove nodes from a queue.

a)

LIFO, Last In First Out

b)

FIFO, First In First Out

c)

Both a and b

d)

none

59.
........ form of access is used to add remove nodes from a stack.
a)
LIFO
b)
Fifo
c)
none
d)
all
60.

Consider the following operation performed on a stack of size 5.

Push(1);

Pop();

Push(2);

Push(3);

Pop();

Push(4);

Pop();

Pop();

Push(5);

After the completion of all operation, the number of elements present on stack are

a)

1

b)

2

c)

3

d)

4

61.

The following circular queue can accommodate a maximum six elements with the following data

front = 2 rear = 4

queue = ____; L ; M; N; ___; ___

What will happen after ADD O operation takes place?

a)

front = 2 rear = 5

queue = ______; L, M, N, O, ___

b)

ront = 3 rear = 5

queue = L, M, N, O, ___

c)

front = 3 rear = 4

queue = ______; L, M, N, O, ___

d)

ront = 2 rear = 4

queue = L, M, N, O, ___

62.

What method is used to add an element to a Queue?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

63.

What method is used to add an element to a Stack?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

64.

Which method is called in a POP() method

a)

IsEmpty()

b)

IsFull()

65.

What will be the post fix expression for the following infix expression a+b*c/d

a)

ab+c*/d

b)

ab+c*/d

c)

ab*c+/d

d)

abc*d/+

66.

Circular queue is also known as

a)

circular buffer

b)

ring buffer

c)

curve buffer

d)

rotating buffer

67.

One difference between stack and queue?

a)

queues require dynamic memory,but stack do not

b)

stacks use two ends of the structure,queue use only one

c)

stacks requires dynamic memory ,but queues do not

d)

queues uses two ends of the structure,stack use only one

68.

If the element "A B C D" are placed in a stack and are deleted one at a time

in what order will they be removed?

a)

ABCD

b)

DBCA

c)

DCBA

d)

DABC

69.

Entries in a stack are “ordered”. What is the meaning of this statement?

a)

a collection of stacks is sortable

b)

stack entries may be compared with the '<' operation

c)

the entries are stored in a linked list

d)

there is a Sequential entry that is one by one

70.

Consider Stack is implemented using the array.

#define MAX 10

struct STACK

{

int arr[MAX]

int top = ___________;

}

What will be the initial value with which top is initialized.

a)

0

b)

-1

c)

garbage

d)

1

71.

A data structure in which elements can be inserted or deleted at/from

both the ends but not in the middle is?

a)

queue

b)

circular queue

c)

dequeue

d)

priority queue

72.

In linked list implementation of a queue,the important condition for a queue to be empty is?

a)

REAR is NULL

b)

FRONT is 1

c)

REAR is 1

d)

FRONT is NULL

73.

What are the attributes to the BankAccount class?

a)

Deposit & withdrawal

b)

owner & balance

c)

BankAccount

d)

string & Dollars

74.

What are the Class Name to the BankAccount class?

a)

Deposit & withdrawal

b)

owner & balance

c)

BankAccount

d)

string & Dollars

e)

I hate Mr. Bugusky

75.

What are the functions to the BankAccount class?

a)

Deposit & withdrawal

b)

owner & balance

c)

BankAccount

d)

string & Dollars

e)

I hate Mr. Bugusky

76.

What of the following is a callable function?

a)

radius

b)

getArea()

c)

center

d)

getCircumference()

e)

setCenter(3,4)

77.

What is an argument all classes need to initialize?

a)

self

b)

name

c)

class

d)

I hate mr. B

e)

keyword

78.

In the statement

Bank tom = Bank(5000.0);

Which is the class?

a)

Bank

b)

tom

c)

new

d)

5000.0

79.

In the statement

Bank tom = Bank(5000.0);

Which is the object?

a)

Bank

b)

tom

c)

new

d)

5000.0

80.
How many objects can be made from a class?  
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
81.

What is a Python class?

a)

A function to create an object.

b)

A template (blueprint) for creating objects.

c)

A procedure related to an object.

d)

A process that repeats are directed.

82.

What is the keyword to create a class?

a)

import

b)

__int__

c)

class

d)

def

83.

Identify the code that properly creates an instance of a class named Car.

a)

camero.car(make, model)

b)

tesla = car.make()

c)

mustang = Car(make,model)

d)

porsche = car.make.model()

84.

Identify the initialization method for a Car class.

a)

class init(self, make, model):

b)

class__init__:

c)

def __init__(self, make, model):

d)

def __init__(self, make, model):

85.

What choice correctly defines a class called NFL_Player with attributes name and overall.

a)

class NFL_Player:

def __init__(self, name, overall):

self.name = name

self.overall = name

b)

class NFL_Player()

def __init__(self, name, overall):

self.name = name

self.overall = name

c)

class NFL_Player:

def __init__(name, overall):

self.name = name

self.overall = name

d)

class NFL_Player()

def __init__(name, overall):

self.name = name

self.overall = name

e)

I don't know.....

86.

Why do we make variable or objects global?

a)

So people on any part of the world can see it. Across the flat earth.

b)

Its good practice.

c)

They are temp and only exist inside the function or class that contains them. Therefore accessible anywhere.

d)
87.

Who would win a battle between, Darth Vader vs. Yoda?

a)

Darth Vader

b)

Yoda

88.

What is cooler, Mandalorian or Black Mirror?

a)

Mandalorian

b)

Capt. James T. Kirk

c)

No opinion

89.

Birthday = True

Is today Mr. Bugusky's birthday?

a)

Yes

b)

No

c)
d)
90.

Features of Python

a)

Easy to learn and read

b)

Portable

c)

GUI programming

d)

All of the above