Q1. What are the basic data types in Python?
Python has several built-in data types: numeric (int, float, complex), string (str), boolean (bool), sequence (list, tuple, range), mapping (dict), set (set, frozenset), and NoneType. They are dynamic and immutable/mutable depending on type.
Q2. What is the difference between int and float?
int represents integer numbers without decimal points, arbitrary precision. float represents floating-point numbers (decimal). Division of integers can produce float. Use int() and float() for conversion.
Q3. What is a string in Python and how is it represented?
A string is an immutable sequence of characters, enclosed in single or double quotes. Triple quotes for multi-line strings. Strings support indexing, slicing, and many methods. Example:
s = "Hello"
print(s[1:4])Q4. What is the difference between mutable and immutable data types?
Mutable objects can be changed after creation (e.g., list, dict, set). Immutable objects cannot be changed; any modification creates a new object (e.g., int, float, str, tuple). This affects memory and performance.
Q5. What is None in Python?
None is a singleton object used to represent null or absence of a value. It is of type NoneType. It is often used as a default return value for functions that don't return anything, or as a placeholder.
