1. What will be the output of the following code?
L = ["India", "Incredible", "Bharat"] print(L[1][0] + L[2][-
1])
a) IT b) it c) It d) It
2. Consider the given expression: print(1919 or not 75>30) Which of the following will be the correct
output of the given expression?
a) True b) False c) Null d) No output
3. What will be the output of the following Python code? str= "Soft Skills" print(str[-3::-3])
a) lSf b) Stkl c) StKi d) l
4. Write the output of the following Python code :
for k in range(7,40,6):
print ( k + '-' )
5. What will be the output of the following Python statement:
print(10-3**2**2+144/12)
6. State if the following statement is True or False: Using the statistics module, the output of the below
statements will be 20:
import statistics
[Link]([10, 20, 10, 30, 10, 20, 30])
7. What will be the output of the following Python code?
my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"}
print(my_dict.get("profession", "Not Specified"))
a) Alicia b)DELHI c)None d)Not Specified
8. What possible output is expected to be displayed on the screen at the time of execution of the Python
program from the following code?
import random L=[10,30,50,70]
Lower=[Link](2,2)
Upper=[Link](2,3)
for K in range(Lower, Upper+1):
print(L[K], end="@")
a) 50@70@ b) 90@ c) 10@30@50@ d) 10@30@50@70@
9. What will be the output of the following Python code?
i=5
print(i,end='@@')
def add():
global i
i = i+7
print(i,end='##')
add()
print(i)
a) 5@@12##15 b) 5@@5##12 c) 5@@12##12 d)12@@12##12
10. Assertion (A): The expression (1, 2, 3, 4).append(5) in Python will modify the original sequence
datatype.
Reason (R): The append() method adds an element to the end of a list and modifies the list in place.
a) Both A and R are True and R is the correct explanation for A.
b) Both A and R are True and R is not the correct explanation for A.
c) A is True but R is False.
d) A is False but R is True.
11. Explain the difference between explicit and implicit type conversion in Python with a suitable example.
12. Explain the difference between break and continue statements in Python with a suitable example.
13. The code provided below is intended to remove the first and last characters of a given string and
return the resulting string. However, there are syntax and logical errors in the code.
Rewrite it after removing all the errors. Also, underline all the corrections made.
define remove_first_last(str):
if len(str) < 2:
return str
new_str = str[1:-2]
return new_str
result = remove_first_last("Hello")
Print("Resulting string: " result)
14. A. (Answer using Python built-in methods/functions only):
I. Write a statement to find the index of the first occurrence of the substring "good" in a string
named review.
II. Write a statement to sort the elements of list L1 in descending order.
15. Predict the output of the following Python code:
text="Learn Python with fun and practice"
print([Link]("with"))
print([Link]("a"))
16. Write a function remove_element() in Python that accepts a list L and a number n. If the number n
exists in the list, it should be removed. If it does not exist, print a message saying "Element not found".
17. Write a Python function add_contact() that accepts a dictionary phone_book, a name, and a phone
number. The function should add the name and phone number to the dictionary. If the name already
exists, print "Contact already exists" instead of updating it.
18. Predict the output of the Python code given below :
emp = {"Arv": (85000,90000),"Ria": (78000,88000),"Jay": (72000,80000),"Tia": (80000,70000)} selected
=[]
for name in emp:
salary = emp[name]
average = (salary[0] + salary[1]) / 2
if average > 80000:
[Link](name)
print(selected)
19. s1="SQP-25"
s2=""
i=0
while i<len(s1):
if s1[i]>=’0’ and s1[i]<='9':
Num=int(s1[i])
Num-=1
s2=s2+str(Num)
elif s1[i]>='A' and s1[i]<='Z':
s2=s2+s1[i+1]
s2=s2+'^' else:
i+=1
else:
print(s2)