What's new

Python Need Help

cr4zyfr0g

Eternal Poster
Established
Joined
Jul 27, 2018
Posts
764
Reaction
1,525
Points
445
Good eve PHC FAM. Need help mga lods lagyan lang sana ng comment every line kahit idea lang sana ako na magtatapos. Thanks in advance mark as solution ko nalang po sa tutulong hehe
Python:
import math
from math import sqrt
def solveAreasquare(a):
      area = a*a
      return area
def solvePerimetersquare(a):
      perimeter = a*4
      return perimeter
def solveArearectangle(l,w):
      area = l*w
      return area
def solvePerimeterrectangle(l,w):
      perimeter = (l + w )*2
      return perimeter
def solveAreatriangle(a,b):
      area = a*b/2
      return area
def solvePerimetertriangle(a,b,c):
      perimeter = a + b + c
      return perimeter
def solveAreahexagon(h):
      area = ((3*(3**(1/2)))/2)*h
      return area
def solvePerimeterhexagon(h):
      perimeter = 6*h
      return perimeter
def solveAreapentagon(p):
      area = (sqrt(5 * (5 + 2 * (sqrt(5)))) * p * p) / 4
      return area
def solvePerimeterpentagon(p):
      perimeter = p*5
      return perimeter

print("Solve the area and perimeter")
print("1.Square")
print("2.Rectangle")
print("3.Triangle")
print("4.Hexagon")
print("5.Pentagon")
print("0.Exit")

choice = input("Choose the shape")
while choice !="0":
      if choice == "1":
            a = int(input("Side of the square"))
            print("Area of the square", solveAreasquare(a))
            print("Perimeter of the square", solvePerimetersquare(a))
            choice = input("Choose the shape")
      elif choice == "2":
            w = int(input("Width of the rectangle"))
            l = int(input("Length of the rectangle"))
            print("Area of the square", solveArearectangle(l,w))
            print("Perimeter of the square", solvePerimeterrectangle(l,w))
            choice = input("Choose the shape")
      elif choice == "3":
            s1 = int(input("Enter the base"))
            s2 = int(input("Enter the height"))
            s3 = int(input("Enter the side"))
            print("Area of the triangle", solveAreatriangle(s1,s2))
            print("Perimeter of the triangle", solvePerimetertriangle(s1,s2,s3))
            choice = input("Choose the shape")
      elif choice == "4":
            side = int(input("Side of the hexagon"))
            print("Area of the hexagon", solveAreahexagon(side))
            print("Perimeter of the hexagon", solvePerimeterhexagon(side))
            choice = input("Choose the shape")
      elif choice == "5":
            side = int(input("Side of the pentagon"))
            print("Area of the pentagon", solveAreapentagon(side))
            print("Perimeter of the pentagon", solvePerimeterpentagon(side))
            choice = input("Choose the shape")
 

Similar threads

Back
Top