Skip to content

Commit e1ba7ad

Browse files
committed
tmp commit
1 parent 4a506d3 commit e1ba7ad

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

calculate_areas/calculate_areas.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'''Python Projects: Calculate the areas of polygons.
2-
ToDo:
32
=> Display user the options for selecting area of required polygon.
43
=> As per the user selection, ask him the required parameters.
54
=> Show the area of required polygons.
6-
=> Write functions to calculate the area of each polygon.
7-
=> Validate the user input.
5+
=> Write separate functions to calculate the area of each polygon.
6+
=> Validate the user input.
87
'''
98
import helper
109
while True:
@@ -40,7 +39,8 @@
4039
f"The area of square with side {side}: {area:.2f}")
4140

4241
elif user_option == '4':
43-
width = input("Enter height, width (eg. 5, 7): ").split(', ')
42+
height, width = input(
43+
"Enter height, width (eg. 5, 7): ").split(', ')
4444
area = helper.rectangle_area(height, width)
4545
print(
4646
f"The area of rectangle with height {height}, width {width}: {area:.2f}")
@@ -52,12 +52,24 @@
5252
print(
5353
f"The area of trapezium with side1 {side1}, side2 {side2}, height {height}: {area:.2f}")
5454

55-
elif user_option == '5':
56-
side1, side2, height = input(
57-
"Enter side1, side2, height (eg. 5, 7, 9): ").split(', ')
58-
area = helper.trapezium_area(side1, side2, height)
55+
elif user_option == '6':
56+
base, height = input("Enter base, height (eg. 5, 7): ").split(', ')
57+
area = helper.parallelogram_area(base, height)
5958
print(
60-
f"The area of trapezium with side1 {side1}, side2 {side2}, height {height}: {area:.2f}")
59+
f"The area of parallelogram with base {base} and height {height}: {area:.2f}")
60+
61+
elif user_option == '7':
62+
diagonal1, diagonal2 = input(
63+
"Enter diagonal1, diagonal2 (eg. 5, 7): ").split(', ')
64+
area = helper.rhombus_area(diagonal1, diagonal2)
65+
print(
66+
f"The area of rhombus with diagonal1 {diagonal1} and diagonal2 {diagonal2}: {area:.2f}")
67+
68+
elif user_option == '8':
69+
radius = input("Enter radius(eg. 5): ")
70+
area = helper.circle_area(radius)
71+
print(
72+
f"The area of circle with radius {radius}: {area:.2f}")
6173

6274
is_continue = input("Do you want to continue?(yes/no): ")
6375

calculate_areas/helper.py

+16
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ def rectangle_area(height, width):
2424
def trapezium_area(side1, side2, height):
2525
side1, side2, height = float(side1), float(side2), float(height)
2626
return ((side1+side2)*height)/2
27+
28+
29+
def parallelogram_area(base, height):
30+
base, height = float(base), float(height)
31+
return (base*height)
32+
33+
34+
def rhombus_area(diagonal1, diagonal2):
35+
diagonal1, diagonal2 = float(diagonal1), float(diagonal2)
36+
return (diagonal1*diagonal2)/2
37+
38+
39+
def circle_area(radius):
40+
radius = float(radius)
41+
pi = math.pi
42+
return pi*(radius**2)

main.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import Counter
2+
import requests
23

34

45
def get_series(sentence):
@@ -15,7 +16,7 @@ def get_series(sentence):
1516

1617

1718
sentence = "A quick brown fox jumps over the lazy dog"
18-
series = get_series(sentence)
19-
print(series[0])
20-
print(series[1])
21-
print(series[2])
19+
my_series = get_series(sentence)
20+
print(my_series[0])
21+
print(my_series[1])
22+
print(my_series[2])

number_series/series_patterns.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PythonProjects.helper_series as helper_series
1+
import helper_series
22

33
while True:
44
print("==============================================")

0 commit comments

Comments
 (0)