Exam Questions And Answers Practice
Questions with Solutions Newest |
Already Graded A+
Q1. What is the output of print(type(10/2))?
A. int
B. float ✔
C. double
D. str
Explanation: Python's / operator performs true division and always returns
a float.
Q2. Which data type is immutable?
A. list
B. dict
C. set
D. tuple ✔
Explanation: A tuple cannot be changed after creation. Lists, dicts, and
sets are mutable.
Q3. What will this code print? x = "Hello" print(x[1])
, A. H
B. e ✔
C. l
D. o
Explanation: String indexing starts at 0: x[0] = 'H', x[1] = 'e'.
Q4. What is the output of print(2 ** 3)?
A. 6
B. 8 ✔
C. 9
D. 5
Explanation: ** is the exponentiation operator. 23=823=8.
Q5. Which loop is used when the number of iterations is unknown?
A. for loop
B. while loop ✔
C. nested loop
D. foreach loop
Explanation: A while loop runs until a condition becomes False, making
it ideal for unknown iteration counts.
Q6. What does the break statement do in a loop?
, A. Skips one iteration
B. Exits the loop completely ✔
C. Restarts the loop
D. Does nothing
Explanation: break terminates the entire loop immediately.
Q7. What is the result of len([1, 2, 3, 4])?
A. 3
B. 4 ✔
C. 5
D. 6
Q8. Which operator is used for integer division in Python?
A. /
B. %%
C. // ✔
D. \
Q9. What is the output of print("Hello" + " " + "World")?
A. Hello World ✔
B. Hello+World
C. HelloWorld
D. Error
, Q10. What is the value of 10 % 3?
A. 1 ✔
B. 2
C. 3
D. 0
Q11. Which is a valid Python variable name?
A. 2variable
B. variable-2
C. variable_2 ✔
D. variable 2
Q12. What does the append() method do?
A. Adds an element to the end of a list ✔
B. Removes an element from a list
C. Inserts an element at a specific index
D. Sorts the list
Q13. What is the output of bool([])?
A. True
B. False ✔