Font size
WorksheetsKIT PYTHON
Total questions: 90
Worksheet time: 1hrs 13mins
Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
What will be the value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
What will be the output of the following Python statement?
>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc
What will be the output of the following Python code?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a) olleh
b) hello
c) h
d) o
What will be the output of the following Python code?
>>>str1="helloworld"
>>>str1[::-1]
a) dlrowolleh
b) hello
c) world
d) helloworld
What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6
Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
a) 5
b) 4
c) None
d) Error
Suppose list1 is [2445,133,12454,123], what is max(list1)?
a) 2445
b) 133
c) 12454
d) 123
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
a) [2, 33, 222, 14]
b) Error
c) 25
d) [25, 14, 222, 33, 2]
If a=(1,2,3,4), a[1:-1] is _________
a) Error, tuple slicing doesn’t exist
b) [2,3]
c) (2,3,4)
d) (2,3)
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
What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
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) {1: ‘A’, 2: ‘B’, 3: ‘C’}
b) Method update() doesn’t exist for dictionaries
c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}
d) {4: ‘D’, 5: ‘E’}
What is the output of the following piece of code when executed in Python shell?
>>> a=("Check")*3
>>> a
(‘Check’,’Check’,’Check’)
* Operator not valid for tuples
(‘CheckCheckCheck’)
Syntax error
Is the following piece of code valid?
>>> a=(1,2,3,4)
>>> del a
No because tuple is immutable
Yes, the entire tuple is deleted
No, invalid syntax for del method
Yes, first element in the tuple is deleted
What type of data is: a=[(1,1),(2,4),(3,9)]?
Array of tuples
List of tuples
Tuples of lists
Invalid type
Which of the following is true for a tuple?
Tup = 1,2,3
Tup = (""1,"2)
Tup = (1,2,3,4)
None of the above
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
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':
t[1] = 'qux'
t(1) = 'qux'
t[1:1] = 'qux'
error
If list=[17,23,41,10] then list.append(32) will result
[32,17,23,41,10]
[17,23,41,10,32]
[10,17,23,32,41]
[41,32,23,17,10]
Suppose list=[12,3,22,"mago","hello"], what is list[-6]
Error
None
mango
12
L_names=['Harsh','Amit','Sahil','Viresh']
min(L_names)
'Harsh'
'Amit'
'Viresh'
None of the above
L_names=['Harsh','Amit','Sahil','Viresh']
L_names.pop()
'Harsh'
'Amit'
'Viresh'
None of the above
If L1=[2,4,8,16], L2=[32,64] what is L1+L2
[2,4,8,16,32,64]
[2,4,8,16][32,64]
[2,4,8,16],[32,64]
None of the above
L=[2,4,8,16,32,64] what is L[:2]
[2,4]
[2,4,8]
2,4
None of the above
T=((1,2,3),(3,4))
what is T[1][1]
4
3
2
1
Suppose list1 is [1, 3, 2], What is list1 * 2 ?
[2, 6, 4].
[1, 3, 2, 1, 3]
[1, 3, 2, 1, 3, 2]
[1, 3, 2, 3, 2, 1]
To remove string “hello” from list1, we use which command?
list1.remove(“hello”)
list1.remove(hello)
list.remove(“hello”)
list.remove(hello)
Suppose a tuple T is declared as T=(20,36,34,49), which of the following is incorrect?
print(T[3])
T[3] = 49
print(min(T))
print(T.count(20))
What is the output of the code?
a = (33, 55)
a.append(22)
print(a)
33 55 22
33
55
22
33, 55, 22
Error
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
Given the nested if-else below, what will be the value x when the code is executed successfully.
0
4
2
3
Given the nested if-else structure below, what will be the value of x after code execution completes.
2
0
3
4
What is the output of the following if statement?
False
True
What is the result of the code:
team = Cowboys
if team = Cowboys:
print(Dallas is #1)
Error
Cowboys
Team
Dallas is #1
Which of the following usees FIFO method
Queue
stack
linklist
binary tree
This form of access is used to add and remove nodes from a queue.
LIFO, Last In First Out
FIFO, First In First Out
Both a and b
none
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
1
2
3
4
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?
front = 2 rear = 5
queue = ______; L, M, N, O, ___
ront = 3 rear = 5
queue = L, M, N, O, ___
front = 3 rear = 4
queue = ______; L, M, N, O, ___
ront = 2 rear = 4
queue = L, M, N, O, ___
What method is used to add an element to a Queue?
dequeue()
enqueue()
push()
pop()
What method is used to add an element to a Stack?
dequeue()
enqueue()
push()
pop()
Which method is called in a POP() method
IsEmpty()
IsFull()
What will be the post fix expression for the following infix expression a+b*c/d
ab+c*/d
ab+c*/d
ab*c+/d
abc*d/+
Circular queue is also known as
circular buffer
ring buffer
curve buffer
rotating buffer
One difference between stack and queue?
queues require dynamic memory,but stack do not
stacks use two ends of the structure,queue use only one
stacks requires dynamic memory ,but queues do not
queues uses two ends of the structure,stack use only one
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?
ABCD
DBCA
DCBA
DABC
Entries in a stack are “ordered”. What is the meaning of this statement?
a collection of stacks is sortable
stack entries may be compared with the '<' operation
the entries are stored in a linked list
there is a Sequential entry that is one by one
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.
0
-1
garbage
1
A data structure in which elements can be inserted or deleted at/from
both the ends but not in the middle is?
queue
circular queue
dequeue
priority queue
In linked list implementation of a queue,the important condition for a queue to be empty is?
REAR is NULL
FRONT is 1
REAR is 1
FRONT is NULL
What are the attributes to the BankAccount class?
Deposit & withdrawal
owner & balance
BankAccount
string & Dollars
What are the Class Name to the BankAccount class?
Deposit & withdrawal
owner & balance
BankAccount
string & Dollars
I hate Mr. Bugusky
What are the functions to the BankAccount class?
Deposit & withdrawal
owner & balance
BankAccount
string & Dollars
I hate Mr. Bugusky
What of the following is a callable function?
radius
getArea()
center
getCircumference()
setCenter(3,4)
What is an argument all classes need to initialize?
self
name
class
I hate mr. B
keyword
In the statement
Bank tom = Bank(5000.0);
Which is the class?
Bank
tom
new
5000.0
In the statement
Bank tom = Bank(5000.0);
Which is the object?
Bank
tom
new
5000.0
What is a Python class?
A function to create an object.
A template (blueprint) for creating objects.
A procedure related to an object.
A process that repeats are directed.
What is the keyword to create a class?
import
__int__
class
def
Identify the code that properly creates an instance of a class named Car.
camero.car(make, model)
tesla = car.make()
mustang = Car(make,model)
porsche = car.make.model()
Identify the initialization method for a Car class.
class init(self, make, model):
class__init__:
def __init__(self, make, model):
def __init__(self, make, model):
What choice correctly defines a class called NFL_Player with attributes name and overall.
class NFL_Player:
def __init__(self, name, overall):
self.name = name
self.overall = name
class NFL_Player()
def __init__(self, name, overall):
self.name = name
self.overall = name
class NFL_Player:
def __init__(name, overall):
self.name = name
self.overall = name
class NFL_Player()
def __init__(name, overall):
self.name = name
self.overall = name
I don't know.....
Why do we make variable or objects global?
So people on any part of the world can see it. Across the flat earth.
Its good practice.
They are temp and only exist inside the function or class that contains them. Therefore accessible anywhere.
Who would win a battle between, Darth Vader vs. Yoda?
Darth Vader
Yoda
What is cooler, Mandalorian or Black Mirror?
Mandalorian
Capt. James T. Kirk
No opinion
Birthday = True
Is today Mr. Bugusky's birthday?
Yes
No
Features of Python
Easy to learn and read
Portable
GUI programming
All of the above
