0% found this document useful (0 votes)
5 views

Python_Basics_Questions

Uploaded by

7934japan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python_Basics_Questions

Uploaded by

7934japan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Basics and Data Types - Practice Questions

### Multiple Choice Questions (MCQs)


1. Which of the following is not a feature of Python?
A. Interpreted Language
B. Case-sensitive
C. Static typing
D. Supports Object-Oriented Programming
Answer: C

2. What will be the output of the following Python code?


print("Hello, World!")
A. Hello, World!
B. hello world!
C. hello, World!
D. Error
Answer: A

3. Which of these is a mutable data type in Python?


A. String
B. Tuple
C. List
D. None
Answer: C

4. What is the result of `5 // 2` in Python?


A. 2
B. 2.5
C. 3
D. None of these
Answer: A

5. What does the keyword `is` check in Python?


A. Membership
B. Identity
C. Equality
D. None of these
Answer: B

### True/False
6. Python supports both interactive mode and script mode for
execution.
Answer: True

7. The operator `in` is used to check identity in Python.


Answer: False

8. Variables in Python need to be declared with a data type before


use.
Answer: False

9. A tuple is immutable, while a list is mutable in Python.


Answer: True
10. Logical errors occur when the program runs but produces
incorrect results.
Answer: True

### Fill in the Blanks


11. The Python keyword used to define a function is __________.
Answer: def

12. __________ errors occur when there is a violation of Python


syntax rules.
Answer: Syntax

13. A variable on the left-hand side of the assignment operator is


called __________.
Answer: l-value

14. Boolean data types in Python can have two possible values:
__________ and __________.
Answer: True, False

15. In Python, the operator used for exponentiation is __________.


Answer: **

### Short Questions


16. Define mutable and immutable data types with examples.
Answer:
- Mutable Data Types: Can be modified after creation. Example:
List, Dictionary.
- Immutable Data Types: Cannot be modified after creation.
Example: String, Tuple.

17. What is the difference between interactive mode and script mode
in Python?
Answer:
- Interactive Mode: Code is executed line by line in the Python
shell.
- Script Mode: Code is saved in a file and executed all at once.

18. What are Python tokens? Name them.


Answer: Tokens are the smallest meaningful units in Python. Types
include Keywords, Identifiers, Literals, Operators, and Punctuators.

19. Explain the concept of type conversion in Python with an


example.
Answer:
- Explicit Conversion: Done manually by the programmer using
functions like `int()`, `float()`, etc.
- Implicit Conversion: Done automatically by Python during
operations.
Example:
a=5
b = 2.5
result = a + b # Implicit conversion of int to float
20. What is the precedence of operators? Provide an example.
Answer: Precedence determines the order in which operators are
evaluated in an expression.
Example:
result = 5 + 2 * 3 # Multiplication is performed first
# result = 11

### Scenario-Based Questions


21. Write a Python script to calculate the area of a rectangle, taking
length and width as input.
Answer:
length = float(input("Enter length: "))
width = float(input("Enter width: "))
area = length * width
print("Area of the rectangle is:", area)

22. Identify and correct the errors in the following code:


x=5
if x > 3
print("x is greater than 3")
Answer:
x=5
if x > 3:
print("x is greater than 3")

You might also like