Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions area_of_rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys



def area_of_rectangle(height, width = None):
"""
Returns the area of a rectangle.
Expand All @@ -29,24 +30,38 @@ def area_of_rectangle(height, width = None):
>>> area_of_rectangle (7, 2)
14
"""
if width:

height = int(height)
# print("height is:", height)
width = int(width)
# print("width is:",width)

if width == None:
width = height


area = height * width
return area

if __name__ == '__main__':
# print("len is ",len(sys.argv))
if (len(sys.argv) < 2) or (len(sys.argv) > 3):
message = (
"{script_name}: Expecting one or two command-line arguments:\n"
"\tthe height of a square or the height and width of a "
"rectangle".format(script_name = sys.argv[0]))
sys.exit(message)
height = sys.argv[1]
width = height
if len(sys.argv) > 3:
width = sys.argv[1]
# print("h is ",height)
if len(sys.argv) == 2:
width = height
else:
width = sys.argv[2]
#if len(sys.argv) > 3:
# width = sys.argv[1]

area = area_of_rectangle(height, width)
# print(area)

message = "The area of a {h} X {w} rectangle is {a}".format(
h = height,
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pandas
plotly
matplotlib