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

Chapter 02 (Python)

The document contains several Python programs demonstrating basic concepts such as calculating the area of a circle from its diameter, identifying data types of variables, and taking user input for age. It also includes a modification of a program to calculate the average of two numbers instead of their sum. Each program is accompanied by example outputs to illustrate the results.

Uploaded by

kunalbarmase88
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Chapter 02 (Python)

The document contains several Python programs demonstrating basic concepts such as calculating the area of a circle from its diameter, identifying data types of variables, and taking user input for age. It also includes a modification of a program to calculate the average of two numbers instead of their sum. Each program is accompanied by example outputs to illustrate the results.

Uploaded by

kunalbarmase88
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# Question - Take diameter as input and calculate the area of a circle.

diameter = int(input("Inter the value of diameter: "))


radius = diameter/2
area = 3.14 * (radius ** 2)
print("Radius of the circle is", radius)
print("Area of circle is", area)
OUTPUT :

Inter the value of diameter: 50

Radius of the circle is 25.0

Area of circle is 1962.5

2. #Data Types program

food= "Samosa"

age= 25
area= 670.98
name= "Khushi"

print("Data type of variable name is", type(name))


print(type(area))
OUTPUT :

Data type of variable name is <class 'str'>

<class 'float'>

3. # program to take age as input and print value entered and its data
type age = input("Enter your age : ")

print("Value entered is :", age)

print("Data type is : ", type(age))


OUTPUT :Enter your age : 25

Value entered is : 25

Data type is : <class 'str'>

#Modify this program to find the average of two numbers instead of the
sum
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
average = (a + b) / 2
print("The average is:", average)
OUTPUT : Enter first number: 10

Enter second number: 20


The average is: 15.0

You might also like