Python Assignment Application Type
Python Assignment Application Type
USN: ________________________
3. A string is immutable in Python? Every time when we modify the string, Python
Always create a new String and assign a new string to that variable.
A. True
B. False
Page 1 of 10
5. What is the output of the following code?
var= "James Bond"
print(var[2::-1])
A. Jam
B. dno
C. maJ
D. dnoB semaJ
7. Can we use the “else” block for for loop? For example:
for i in range(1, 5):
print(i)
else:
print("this is else block statement" )
A. No
B. Yes
Page 4 of 10
22. Select all the right ways to create a string literal Ault'Kelly
A. str1 = 'Ault\\'Kelly'
B. str1 = 'Ault\'Kelly'
C. str1 = """Ault'Kelly"""
23. In Python 3, what is the output of type(range(5)). (What data type it will return).
A. int
B. list
C. range
D. None
25. Please select the correct expression to reassign a global variable “x” to 20 inside a
function fun1()
x = 50
def fun1():
# your code to assign global x = 20
fun1()
print(x) # it should print 20
A. global x =20
B. global var x
x = 20
C. global.x = 20
D. global x
x = 20
Page 5 of 10
28. What is the result of print(type([]) is list)
A. False
B. True
Page 6 of 10
34. What is the output of the following list operation
sampleList = [10, 20, 30, 40, 50]
print(sampleList[-2])
print(sampleList[-4:-1])
A. 40
[20, 30, 40]
B. IndexError: list index out of range
Page 8 of 10
45. Dictionary keys must be immutable
A. True
B. False
48. Select the correct ways to get the value of marks key.
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
A. m = student.get(2)
B. m = student.get('marks')
C. m = student[2])
D. m = student['marks'])
50. Items are accessed by their position in a dictionary and All the keys in a dictionary
must be of the same type.
A. True
B. False
Page 9 of 10
52. What is the output of the following
sampleDict = dict([
('first', 1),
('second', 2),
('third', 3)
])
print(sampleDict)
A. [ (‘first’, 100), (‘second’, 200), (‘third’, 300) ]
B. SyntaxError: invalid syntax
C. {‘first’: 1, ‘second’: 2, ‘third’: 3}
54. Write a program that determines whether a given word or number or phrase is a
palindrome. Palindrome means it reads the same both forward and backward. Eg:
121121, MALAYALAM
55. Create a basic calculator for addition, subtraction, multiplication and division
arithmetic operations. Scientific features like square root and exponentiation have
to be included.
Page 10 of 10