python program to calculate the area of a circle.
PI = 3.14
r = float(input("Enter the radius of a circle:"))
area = PI * r * r
print("Area of a circle = %.2f" %area)
Python program to find the area of a triangle
# Three sides of the triangle is a, b and c:
a = float(input('Enter first side: '))
b = float(input('Enter second side: '))
c = float(input('Enter third side: '))
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)
Find Area of Rectangle
print("Enter Length of Rectangle: ")
l = float(input())
print("Enter Breadth of Rectangle: ")
b = float(input())
a = l*b
print("\nArea = ", a)
Program to find the position of min and max elements of a list in
Python
# declare a list of Integers
list = [10, 1, 2, 20, 3, 20]
# min element's position/index
min = [Link] (min(list))
# max element's position/index
max = [Link] (max(list))
# printing the position/index of min and max elements
print ("position of minimum element: ", min)
print ("position of maximum element: ", max)
Python Program to Read the marks of three subjects and display
the Total, Average
a = int(input("Enter the marks of first subject: "))
b = int(input("Enter the marks of second subject: "))
c = int(input("Enter the marks of third subject: "))
total = a+b+c
avg = total/3
print("Total marks: ",total)
print("Average marks: ",avg)
Sum of First N Natural Numbers
n=int(input("Enter a number: "))
sum1 = 0
while(n > 0):
sum1=sum1+n
n=n-1
print("The sum of first n natural numbers is",sum1)
How To Calculate Mean, Median And Mode In Python
import statistics
data = [220, 100, 190, 180, 250, 190, 240, 180, 140, 180,
190]
# Finding Mean
print("\nMean: ", [Link](data))
# Finding Median
print("Median: ", [Link](data))
# Finding Single Mode
print("Single Mode: ", [Link](data))
# Finding Multiple Modes
print("Mode: ", [Link](data))