1. Explain different data types in Python?
Python supports several data types:
• int – Integer numbers (e.g., 10)
• float – Decimal numbers (e.g., 10.5)
• str – Sequence of characters (e.g., "Hello")
• bool – True or False values
• list – Ordered and mutable collection
• tuple – Ordered and immutable collection
• dict – Key–value pairs
• set – Unordered unique elements
2. How many types of loops are available in Python? Explain them with example.
Python has two main loops:
• for loop – Used to iterate over a sequence
Example:
for i in range(5):
print(i)
• while loop – Runs until a condition becomes false
Example:
i=1
while i <= 5:
print(i)
i += 1
3. What is function? Why to use functions? Explain main types of functions in Python.
A function is a reusable block of code used to perform a specific task.
Why use functions?
• Reduces code repetition
• Makes program organized and modular
• Easier debugging
Types:
• Built-in functions (e.g., print(), len(), input())
• User-defined functions (created using def keyword)
4. What is a string in Python? Write any 5 string methods.
A string is a sequence of characters enclosed in quotes.
Methods:
• upper()
• lower()
• strip()
• replace()
• split()
5. What is Data Visualization? Which library is used for Data Visualization in Python? Name types
of charts available in that library.
Data Visualization means representing data in graphical or pictorial form.
Python library: matplotlib
Types of charts:
• Line chart
• Bar chart
• Pie chart
• Histogram
• Scatter plot
6. What is List in Python? Explain with example - how to create list, access item in a list, update list
and delete items from a list.
A list is an ordered, mutable collection of items.
Example:
Create list:
numbers = [10, 20, 30]
Access item:
numbers[1] → 20
Update list:
numbers[1] = 50 → [10, 50, 30]
Delete item:
del numbers[0] → [50, 30]
7. Write types of loops available in C programming?
C has three types of loops:
• for loop
• while loop
• do–while loop