Showing posts with label IP CLASS XI Lab Programs. Show all posts
Showing posts with label IP CLASS XI Lab Programs. Show all posts

Sunday, 30 August 2020

To calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle in python

Question 3:To calculate perimeter/circumference and area of shapes such as  triangle, rectangle, square and circle.

#We will make use of user defined python functions for this task.
#we will import math library to use sqrt(), this will used to #calculate square root.

import math
def area_square(a):
    area1=float(a*a);
    print("Area of square is:",area1)
def area_circle(r):
    area2=float(3.14*r*r);
    print("Area of circle is:",area2)
def area_rectangle(a,b):
    area3=float(a*b);
    print("Area of rectangle is:",area3)
def area_triangle(x,y):
    area4=float((x*y)/2);
    print("Area of triangle is:",area4)
def peri_square(a):
    peri1=float(4*a);
    print("Perimeter of square is:",peri1)
def peri_circle(r):
    peri2=float(2*3.14*r);
    print("Perimter of circle is:",peri2)
def peri_triangle(a,b):
    hypotenuse=float(math.sqrt(a*a+b*b))
    peri3=float(a+b+hypotenuse)
    print("Perimter of right angled triangle is:",peri3)
def peri_rectangle(a,b):
    peri4=float(2*(a+b))
    print("Perimter of rectangle is:",peri4)

side=float(input("enter the side of square:"))
area_square(side)
print()
peri_square(side)
radius=float(input("enter the radius of circle:"))
area_circle(radius)
peri_circle(radius)
length=float(input("enter the length of rectangle:"))
breadth=float(input("enter the breadth of rectangle:"))
area_rectangle(length,breadth)
peri_rectangle(length,breadth)
base=float(input("enter the base of right angled triangle:"))
height=float(input("enter the height of right angled triangle:"))
area_triangle(base,height)
peri_triangle(base,height)

Source Code:


Python program to
calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle.


Python program to calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle.

Output:


Output

Saturday, 29 August 2020

To find sale price of an item with given cost and discount (%).

Question 2: To find sale price of an item with given cost and discount (%).

Solution:
#To find sale price of an item with given cost and discount (%).
cost_price=float(input("Enter the price of item:"))
discount=float(input("Enter the discount %:"))
selling_price=float(((100-discount)/cost_price)*100)

print("The selling price of item is:",selling_price)

Source Code:


Source code:To find selling
 price of an item with given cost and discount (%).








Output:


Output of Source Code.

Class XI IP Python LAB Programs


Dear Students, I am making sincere efforts to provide you the programs that you have to run as a class XI IP student in your labs.


Question 1: To find average and grade for given marks.

Solution:
#To find average and grade for given marks.
eng=float(input("Enter English Marks:"))
cs=float(input("Enter Computer Science Marks:"))
phy=float(input("Enter Physics Marks:"))
chem=float(input("Enter Chemistry Marks:"))
maths=float(input("Enter Mathematics Marks:"))
average=float((eng+cs+phy+chem+maths)/5)
print("Average of Marks is",average)
if average>90:
print("You scored GRADE A")
elif average<=90 and average >80:
print("You scored GRADE B")
elif average<=70 and average <80:
print("You scored GRADE C")
elif average<=60 and average <70:
print("You scored GRADE D")
elif average<=50 and average <60:

print("You scored GRADE E")

Source Code:


Source code for how to find average and grades of given marks
















Output: