HOMEWORK QUESTIONS
MCQs
1. Which of the following statements about Python is correct?
(a) It is a compiled language
(b) It is an interpreted language
(c) It is machine dependent
(d) It requires explicit data type declaration
2. Identify the correct statement about Interactive Mode:
(a) Entire program is written and executed together
(b) Code is executed line by line
(c) It does not show output immediately
(d) It requires compilation
3. Which of the following is NOT a valid token in Python?
(a) Keywords
(b) Identifiers
(c) Literals
(d) Comments
4. Which of the following is an invalid identifier?
(a) _value
(b) data123
(c) 2value
(d) value_2
5. Which literal represents absence of value in Python?
(a) False (b) 0 (c) None (d) Null
6. Which of the following is a valid complex literal?
(a) 3+2j (b) 3+2k (c) 3+2i (d) 3+2l
7. What will be the type of input() function return value?
(a) int (b) float (c) str (d) bool
8. Which operator has highest precedence?
(a) + (b) * (c) ** (d) and
9. Which of the following is TRUE about strings?
(a) Mutable (b) Indexed (c) Unordered (d) Cannot contain spaces
10. What will be the output?
a = "Python"
print(a[-2])
(a) h (b) o (c) n (d) t
11. Which data type is immutable?
(a) List
(b) Dictionary
(c) Set
(d) Tuple
12. Which data type does NOT allow duplicate values?
(a) List
(b) Tuple
(c) Set
(d) Dictionary
13. Which of the following is a correct dictionary?
(a) {1,2,3}
(b) {"a":1,"b":2}
(c) ("a":1,"b":2)
(d) ["a":1,"b":2]
14. What will be the output?
a=5
b=2
c=a/b
print(type(c))
(a) int (b) float (c) str (d) bool
15. Which type conversion is performed automatically by Python?
(a) Explicit (b) Manual (c) Implicit (d) Forced
16. What will be the output?
a, b, c = 10, 20, 30
print(b)
(a) 10 (b) 20 (c) 30 (d) Error
17. Which of the following is NOT a feature of Python?
(a) Platform independent
(b) Open source
(c) Strongly typed only
(d) Simple syntax
18. What will be the output?
print("Hello", "World", sep="-")
(a) Hello World (b) Hello-World (c) HelloWorld (d) Error
19. Which operator is used for membership testing?
(a) ==
(b) is
(c) in
(d) &
MCQs (21–40)
20. Which of the following is a valid hexadecimal literal?
(a) 0x1G
(b) 0xA3
(c) 0xZ12
(d) 0x12H
21. Which of the following is a valid octal number?
(a) 0o17
(b) 017
(c) 0x17
(d) 0b17
22. Which operator is used for identity comparison?
(a) == (b) = (c) is (d) in
23. Which of the following punctuators is used for comments?
(a) // (b) # (c) /* */ (d) --
24. What will be the output?
print("Age:", 10+5, "years")
(a) Age: 15 years
(b) Age: 10+5 years
(c) Age: 105 years
(d) Error
24. Which of the following is NOT allowed in identifiers?
(a) Underscore
(b) Digits after first position
(c) Space
(d) Alphabets
25. What will be the output?
a = "5"
b = int(a)
print(b + 2)
(a) 52 (b) 7 (c) Error (d) "52"
26. What will be the output?
a = [1,2,3]
a[1] = 10
print(a)
(a) [1,2,3] (b) [1,10,3] (c) Error (d) None
27. Which of the following is TRUE about tuples?
(a) Mutable (b) Ordered (c) No indexing (d) Uses []
28. Which of the following is TRUE about sets?
(a) Ordered
(b) Allows duplicates
(c) Unindexed
(d) Mutable only
29. What will be the output?
s = {1,2,2,3}
print(s)
(a) {1,2,2,3} (b) {1,2,3} (c) Error (d) [1,2,3]
30. What will be the output?
a=5
b=2
print(a//b)
(a) 2.5 (b) 2 (c) 3 (d) Error
Assertion Reasoning Questions
Directions (for all questions below):
(a) Both Assertion (A) and Reason (R) are true, and R is the correct explanation of A
(b) Both A and R are true, but R is NOT the correct explanation of A
(c) A is true, but R is false
(d) A is false, but R is true
Q1: Assertion (A): Identifiers can start with a number.
Reason (R): Identifiers can contain digits after the first position.
Q2: Assertion (A): input() always returns a string.
Reason (R): Python automatically converts input into integer type.
Q3: Assertion (A): Dictionaries store data in key:value pairs.
Reason (R): Keys in a dictionary must be unique.
Q4: Assertion (A): Comments improve code readability.
Reason (R): Comments are executed by the Python interpreter.
Q5: Assertion (A): The operator “in” is used for membership testing.
Reason (R): It checks whether a value exists in a sequence.
2 MARKS QUESTION
1. What is dynamic typing? Give one example.
2. Differentiate between == and is with example.
3. Differentiate between Mutable and Immutable Data Type.
4. Explain Implicit, Explicit Type Conversion
5. Write a program to input a number and print its square and cube.
6. Write a program to input a string and print:
First character
Last character
Length of string
7. Write a program to count number of vowels in a given string.
8. Evaluate the following expressions (show steps):
(i) 5 + 2 * 3 ** 2
(ii) (10 + 5) // 3
9. Write a program to check whether a number entered by user is even or odd.
10. Write the output of below:
List1 = [10,25,45,68,2,36]
print(List1[-1:-4:-1]
print(List1[2:5]