Skip to content

Commit e7becd5

Browse files
More Functions (#12)
* More Functions * Error on Command 6 System * Fixed Phrasing for Triangle * Better Comments, Better Efficiency
1 parent fdc0568 commit e7becd5

1 file changed

Lines changed: 43 additions & 10 deletions

File tree

version-2.py

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,70 @@
66
Enter 3 for Area of Rectangle
77
Enter 4 for Perimeter of Rectangle
88
Enter 5 for Area of Circle (pi will be 3.14)
9-
Enter 6 for Diameter of Circle
9+
Enter 6 for Diameter of Circle (pi will be 3.14)
10+
Enter 7 for Circumference of Circle (pi will be 3.14)
11+
Enter 8 for Area of Triangle
12+
Enter 9 for Perimeter of Triangle
13+
Enter 10 for Area of Trapezium
1014
>>> """))
1115
except ValueError:
1216
print("You have entered an invalid input. Please try again.")
1317
else:
14-
# Just giving a newline
18+
# Newline
1519
print()
16-
# For square
20+
# For Commad Lines 1 and 2
1721
if cmd in [1, 2]:
1822
length = float(input("Enter length of sides of Square: "))
19-
20-
# For area of square.
23+
# For Command 1
2124
if cmd == 1:
2225
print(length * length)
23-
# For perimeter of square.
26+
# For Command 2
2427
else:
2528
print(4 * length)
2629
elif cmd in [3, 4]:
2730
length = float(input("Enter length of Rectangle: "))
2831
breath = float(input("Enter width of Rectangle: "))
29-
# For area of Rectangle
32+
# For Command 3
3033
if cmd == 3:
3134
print(length * breath)
32-
# For perimeter of Rectangle
35+
# For Command 4
3336
else:
3437
print(2 * (length + breath))
35-
elif cmd in [5, 6]:
38+
# For Command 5,6,7
39+
elif cmd in [5, 6, 7]:
3640
radius = float(input("Enter radius of circle: "))
41+
# For Command 5
3742
if cmd == 5:
3843
print(3.14 * (radius * radius))
44+
# For Command 6
3945
elif cmd == 6:
40-
print(3.14 * radius)
46+
print(2 * radius)
47+
# For Command 7
48+
else:
49+
print(3.14 * (radius * 2))
50+
# For Command 8
51+
elif cmd == 8:
52+
base = float(input("Enter base of triangle: "))
53+
height = float(input("Enter height of triangle: "))
54+
print(0.5 * base * height)
55+
# For Command 9
56+
elif cmd == 9:
57+
side = float(input("Enter side of triangle: "))
58+
side2 = float(input("Enter second side of triangle: "))
59+
side3 = float(input("Enter third side of triangle: "))
60+
print(side + side2 + side3)
61+
# For Command 10,11
62+
elif cmd in [10,11]:
63+
a = float(input("Enter base of trapezium: "))
64+
b = float(input("Enter top length of trapezium: "))
65+
height = float(input("Enter height of trapezim: "))]
66+
# For Command 10
67+
if cmd == 10:
68+
print(0.5 * (a + b) * height)
69+
# For Command 11
70+
else:
71+
width = float(input("Enter width of trapezium: "))
72+
print((0.5 * (a + b) * height) * width)
73+
# Invalid Input Statement
4174
else:
4275
print("You have entered in an invalid input. Please try again.")

0 commit comments

Comments
 (0)