1. State True or False:
The Python interpreter handles logical errors during code execution.
Ans: False
2. Identify the output of the following code snippet:
text = "PYTHONPROGRAM"
text=text.replace('PY','#')
print(text)
a) #THONPROGRAM
b) ##THON#ROGRAM
c) #THON#ROGRAM
d) #YTHON#ROGRAM
3. Which of the following expressions evaluates to False?
a) not(True) and False
b) True or False
c) not(False and True)
d) True and not(False)
4. What is the output of the expression?
country='International'
print(country.split("n"))
a) ('I', 'ter', 'atio', 'al')
b) ['I', 'ter', 'atio', 'al']
c) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al']
d) Error
5. What will be the output of the following code snippet? message= "World Peace" print(message[-2::-2])
Ans: ce lo
6. What will be the output of the following code? tuple1 = (1, 2, 3) tuple2 = tuple1 tuple1 += (4,) print(tuple1 = = tuple2)
a) True
b) False
c) tuple1
d) Error
7. If my_dict is a dictionary as defined below, then which of the following statements will raise an exception? my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
a) my_dict.get('orange')
b) print(my_dict['apple', 'banana'])
c) my_dict['apple']=20
d) print(str(my_dict))
8. What does the list.remove(x) method do in Python?
a) Removes the element at index x from the list
b) Removes the first occurrence of value x from the list
c) Removes all occurrences of value x from the list
d) Removes the last occurrence of value x from the list
9. If a table which has one Primary key and two alternate keys. How many Candidate keys will this table have?
a) 1
b) 2
c) 3
d) 4
10. Write the missing statement to complete the following code:
file = open("example.txt", "r")
data = file.read(100) _______ #Move the file pointer to the beginning of the file
next_data = file.read(50)
file.close()
Ans: file.seek(0) ( OR file.seek(0,0) )
11. State whether the following statement is True or False: The finally block in Python is executed only if no exception occurs in the try block.
Ans: False
12. What will be the output of the following code?
c = 10
def add():
global c
c = c + 2
print(c, end='#')
add()
c = 15
print(c, end='%')
a) 12%15#
b) 15#12%
c) 12#15%
d) 12%15#
13. Which SQL command can change the degree of an existing relation?
Ans: ALTER
14. What will be the output of the query? SELECT * FROM products WHERE product_name LIKE 'App%';
a) Details of all products whose names start with 'App'
b) Details of all products whose names end with 'App'
c) Names of all products whose names start with 'App'
d) Names of all products whose names end with 'App'
15. In which datatype the value stored is padded with spaces to fit the specified length.
a) DATE
b) VARCHAR
c) FLOAT
d) CHAR
16. Which aggregate function can be used to find the cardinality of a table?
a) sum()
b) count()
c) avg()
d) max()
17. Which protocol is used to transfer files over the Internet?
a) HTTP
b) FTP
c) PPP
d) HTTPS
18. Which network device is used to connect two networks that use different protocols?
a) Modem
b) Gateway
c) Switch
d) Repeater
19. Which switching technique breaks data into smaller packets for transmission, allowing multiple packets to share the same network resources.
Ans: Packet Switching
Q.20 and Q.21 are Assertion(A) and Reason(R) based questions. Mark the correct choice as:
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
20. Assertion (A): Positional arguments in Python functions must be passed in the exact order in which they are defined in the function signature.
Reason (R): This is because Python functions automatically assign default values to positional arguments.
Ans: c) A is True but R is False
21. Assertion (A): A SELECT command in SQL can have both WHERE and HAVING clauses.
Reason (R): WHERE and HAVING clauses are used to check conditions, therefore, these can be used interchangeably.
Ans: c) A is True but R is False