WorksheetsPython Programming Worksheet
Total questions: 20
Worksheet time: 10mins
Which of the following is NOT a feature of Python?
Dynamically typed
Interpreted language
Requires explicit variable declaration with type
Supports multiple programming paradigms
Python is developed by:
James Gosling
Guido van Rossum
Dennis Ritchie
Bjarne Stroustrup
What is the output of print(type(5.0))?
Which of these is an immutable data type in Python?
List
Dictionary
Tuple
Set
What will be the output of bool(0)?
True
False
Error
None
What is the output of 10 // 3 in Python?
3.33
3
4
Error
Which operator has the highest precedence in Python?
** (Exponentiation)
* (Multiplication)
+ (Addition)
and
What does the += operator do?
Addition assignment
Concatenation
Both a and b
None of the above
What will be printed? Python x = 10 if x > 15: print("Hi") elif x > 5: print("Hello") else: print("Bye")
Hi
Hello
Bye
None
Which keyword is used to skip the rest of the current loop iteration?
continue
break
pass
skip
How many times will the following loop run? for i in range(5): print(i)
4
5
6
Infinite
What is the output of this code? i = 0 while i < 3: print(i, end=" ") i += 1 else: print("Done")
0 1 2
0 1 2 Done
Done 0 1 2
Infinite loop
Which loop is guaranteed to execute at least once?
for loop
while loop
do-while loop (does not exist in Python)
None
What is the output of len([1, 2, [3, 4], 5])?
3
4
5
Error
Which method adds an element at the end of a list?
insert()
append()
extend()
add()
What does list1.extend([4,5]) do?
Adds [4,5] as a single element
Adds 4 and 5 as separate elements
Replaces the list
Error
How do you access the last element of a list named mylist?
mylist[-1]
mylist[last]
mylist.end()
mylist.pop()
What is the output of [1,2,3] * 2?
[2,4,6]
[1,2,3,1,2,3]
[1,2,6]
Error
Which of the following creates a shallow copy of a list?
list2 = list1
list2 = list1.copy()
list2 = list1[:]
Both b and c
What does mylist.pop() return?
Removes and returns the last element
Removes the first element
Returns None
Error if list is empty
