Commit 384c734b by arun.uday

new file structure v2

parent e24d6d1b
# Importing modules rectangle, circle, square from scripts
from scripts.core import Circle, Rectangle, Square
from scripts.services.main_service import shapes
# User Inputs
while True:
# checks for calculation choice error
error = 0
shape_choice = input("Enter rectangle/ circle/ square/ quit")
if shape_choice == 'quit':
break
calculation_choice = input("Enter area/ perimeter")
# choice is rectangle
if shape_choice == 'rectangle':
rect_length = int(input("Enter the length"))
rect_breadth = int(input("Enter the breadth"))
if calculation_choice == 'area':
print(f'Area : {Rectangle.Area(rect_length, rect_breadth).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Rectangle.Perimeter(rect_length, rect_breadth).display_perimeter()}')
else:
error = 1
# choice is circle
elif shape_choice == 'circle':
circle_radius = int(input("Enter the radius"))
if calculation_choice == 'area':
print(f'Area : {Circle.Area(circle_radius).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Circle.Perimeter(circle_radius).display_perimeter()}')
else:
error = 1
# choice is square
elif shape_choice == 'square':
square_side = int(input("Enter the side"))
if calculation_choice == 'area':
print(f'Area : {Square.Area(square_side).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Square.Perimeter(square_side).display_perimeter()}')
else:
error = 1
# invalid choice
else:
print("Please check the spelling.....")
# invalid calculation choice
if error == 1:
print("Calculation choice error....")
# calling services
print("This program is to find the area and perimeter of shapes.....")
shapes()
# Importing modules rectangle, circle, square from scripts
from scripts.core.handlers import Circle, Rectangle, Square
# User Inputs
def shapes():
while True:
# checks for calculation choice error
error = 0
shape_choice = input("Enter rectangle/ circle/ square/ quit")
if shape_choice == 'quit':
break
calculation_choice = input("Enter area/ perimeter")
# choice is rectangle
if shape_choice == 'rectangle':
rect_length = int(input("Enter the length"))
rect_breadth = int(input("Enter the breadth"))
if calculation_choice == 'area':
print(f'Area : {Rectangle.Area(rect_length, rect_breadth).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Rectangle.Perimeter(rect_length, rect_breadth).display_perimeter()}')
else:
error = 1
# choice is circle
elif shape_choice == 'circle':
circle_radius = int(input("Enter the radius"))
if calculation_choice == 'area':
print(f'Area : {Circle.Area(circle_radius).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Circle.Perimeter(circle_radius).display_perimeter()}')
else:
error = 1
# choice is square
elif shape_choice == 'square':
square_side = int(input("Enter the side"))
if calculation_choice == 'area':
print(f'Area : {Square.Area(square_side).display_area()}')
elif calculation_choice == 'perimeter':
print(f'Perimeter : {Square.Perimeter(square_side).display_perimeter()}')
else:
error = 1
# invalid choice
else:
print("Please check the spelling.....")
# invalid calculation choice
if error == 1:
print("Calculation choice error....")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment