Section A
Section A
a = 10, b = 20
a, b = b, a
print (a, b)
[a] 10 20 [b] 20 10
[c] 20 20 [d] 10 10
[iii] Which of the following is used to add a comment in Python?
[a] // comment [b] /* comment */
[c] # comment [d] -- comment
[iv] Which of the following is the correct syntax for a Python "if-else"
statement?
[a] if condition { statements }
[b] if condition: statements else: statements
[c] if condition then statements else then statements
[d] if condition: statements else: else_statements
[v] Which of the following is a valid method to add an element to the end of a
list?
[a] append() [b] extend()
[c] insert() [d] add()
[vi] What will be the output of the following Python code?
my_tuple = (1, 2, 3, 4)
print(my_tuple[2])
[a] 1 [b] 2
[c] 3 [d] 4
[vii] Which of the following is used to define a dictionary in Python?
P.T.O
[a] [] [b] ()
[c] {} [d] <>
[viii] Which of the following methods is automatically called when a new
instance of a class is created?
[a] init() [b] call()
[c] str() [d] new()
[ix] What is the correct way to open a file in Python for reading?
[a] open("file.txt", "r") [b] open("file.txt", "w")
[c] open("file.txt", "a") [d] open("file.txt", "rb")
[x] What will be the output of the following Python code?
x=5
while x > 0:
print(x, end=' ')
x -= 1
[a] 5 4 3 2 1 [b] 4 3 2 1 0
[c] 5 4 3 2 [d] Infinite loop
[Section -B]
Short answer type questions [2 X 5 = 10 Marks]
[Section -C]
Long answer type questions [3 X 10 = 30 Marks]
Answer any three Questions.
Q.7 Explain the different data types in Python, such as int, float, boolean, string,
and list. Provide examples of how each data type is used in Python.
Q.8 Describe the process of defining and calling functions in Python. Explain
the concepts of function parameters, return values, local and global
variables, and scope with a detailed example.
Q.9 Explain dictionaries in Python. How to create, access, and modify them?
Q.10 Differentiate between while and for loops in Python. Explain with
examples.
Q.11 Discuss control flow statements (if, if-else, if-elif-else) with examples.
P.T.O