Q: What is Python? Why is it popular?
A: Python is a high-level, interpreted, and general-purpose programming language. Its simplicity and
readability make it popular among beginners and professionals. Python supports multiple
programming paradigms, including procedural, object-oriented, and functional programming. It also
has an extensive standard library and community support, making it suitable for a wide range of
applications.
Q: What are the key features of Python?
A: Python is easy to learn and use, has an extensive library, supports multiple programming
paradigms, is cross-platform, and offers interpreted execution which simplifies debugging.
Q: What are Python's basic data types? Explain with examples.
A: Basic data types in Python include:
- Integer: Whole numbers, e.g., x = 5
- Float: Decimal numbers, e.g., y = 3.14
- String: Characters in quotes, e.g., name = 'Python'
- Boolean: Logical values True or False, e.g., is_valid = True
Q: What is the difference between a list and a tuple in Python?
A: Lists are mutable and enclosed in square brackets [ ], whereas tuples are immutable and
enclosed in parentheses ( ).
Example:
List: fruits = ['apple', 'banana']
Tuple: coordinates = (10, 20)
Q: How do you define a function in Python?
A: Functions are defined using the 'def' keyword followed by the function name and parentheses.