0% found this document useful (0 votes)
10 views2 pages

Python Basics Questions and Answers

The document contains a Q&A section about Python data types, including mutable and immutable types, and provides examples of code outputs. It also includes several programming exercises for calculating averages, tracking expenses, calculating the area of a circle, total expenditure, and converting Fahrenheit to Celsius. Additionally, it explains the input() function and the order of operations in Python using PEDMAS.

Uploaded by

Anurag Singh
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)
10 views2 pages

Python Basics Questions and Answers

The document contains a Q&A section about Python data types, including mutable and immutable types, and provides examples of code outputs. It also includes several programming exercises for calculating averages, tracking expenses, calculating the area of a circle, total expenditure, and converting Fahrenheit to Celsius. Additionally, it explains the input() function and the order of operations in Python using PEDMAS.

Uploaded by

Anurag Singh
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/ 2

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)

You might also like