PythonPrograms 1
PythonPrograms 1
Output: Programs:
Output: Ex. 2: Write Python code to find the product of three numbers
Ex. 3: Write Python code to accept three subject marks from the user and find
calculate Total and Average.
Output:
# Calculate Total and Average
mark1 = int(input("Enter Subject mark 1 :"))
mark2 = int(input("Enter Subject mark 2 :"))
mark3 = int(input("Enter Subject mark 3 :"))
total = mark1 + mark2 + mark3
average = total / 3
print("Total Marks :", total)
print("Average Marks :",average)
Output: Ex. 4: Write Python code to calculate Simple Interest.
# perimeter of a rectangle
l = float(input("Enter Length of a rectangle :"))
b = float(input("Enter Breadth of a rectangle :"))
p = 2 * (l + b)
print("Perimeter of a rectangle :", p)
# area of a circle
r = float(input("Enter radius of a circle :"))
a = 3.14 * r ** 2
print("Area of a circle :", a)
# area of a triangle
b = float(input("Enter base of a triangle :"))
h = float(input("Enter height of a triangle :"))
a = 0.5 * b * h
print("Area of a triangle :", a)
Output: Ex. 8: Write Python code to find the Area of a Rectangle.
# area of a rectangle
l = float(input("Enter length of a rectangle :"))
b = float(input("Enter breadth of a rectangle :"))
a=l*b
print("Area of a rectangle:", a)
# circumference of circle
r = float(input("Enter Radius of a circle :"))
c = 2 * 3.14 * r
print("Circumference of a circle :", c)
Output:
Ex. 10: Write Python code to find the Perimeter of a Square.
# perimeter of a square
s = float(input("Enter side of a square :"))
p=4*s
print("Perimeter of a square :", p)
Output:
Ex. 11: Write Python code to find the Volume of a Sphere.
# volume of a sphere
r = float(input("Enter radius of a sphere :"))
v = (4 / 3) * 3.14 * r * r * r
print("volume of a sphere :", v)
Output:
Ex. 12: Write Python code to find the Volume of the Cylinder.
Output: Ex. 18: Write a program in Python to enter the restaurant bill amount and display
the amount to be paid after deducting 10% discount on the bill and adding
taxes, CGST and SGST at 2.25% each.
Ex. 20: The computer science teacher has asked the students to write a Python
program to input the length of the three sides of a triangle and display its
area using the formula given below. (Here, a, b and care the lengths of the
three sides of a triangle; S is the semi-perimeter and A is the area):
Output:
# Cost of Fencing
X = int(input("Enter field of Length - X:"))
Y = int(input("Enter field of Breadth - Y:"))
# Cost of one meter = Rs.1000
Z = (X*1000) + (Y*1000)
print ("Cost of fencing = ",Z)
Output: Ex. 22: The AXZ Company has given an increase of 8.5% in salary to its employees.
Write a python program to input the salary and display the new salary.