Q1: Answer the following questions
1. What are the two main categories of data types in Python?
Mutable and Immutable data types.
2. Write the output of the following code:
x = 5.7
y = int(x)
print(y)
Output: 5
3. What is the difference between mutable and immutable data types in Python?
Mutable data types can be changed after creation (e.g., list, dictionary), while immutable data types
cannot be changed after creation (e.g., int, float, string, tuple).
4. What is the full form of PEDMAS?
Parentheses, Exponents, Division, Multiplication, Addition, Subtraction
5. In Python, what does the input() function return?
It returns the user input as a string.
Q2: Apply your learning
1. Program to take two numbers and display average:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
average = (num1 + num2) / 2
print("Average:", average)
2. Program to keep track of user's expenses:
name = input("Enter your name: ")
expense = float(input("Enter the amount spent: "))
category = input("Enter the category: ")
print(name, "spent", expense, "on", category + ".")
3. Program to calculate area of a circle:
radius = float(input("Enter radius of the circle: "))
area = 3.14159 * radius * radius
print("Area of the circle is:", area)
4. Program to find total expenditure on stationery:
pen = 25
pencil = 8
notebook = 45
colours = 88
total = pen + pencil + notebook + colours
print("Total expenditure is:", total)
5. Program to convert Fahrenheit to Celsius:
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print("Temperature in Celsius is:", celsius)