Skip to content

Instantly share code, notes, and snippets.

@khayyamsaleem
Created October 16, 2017 14:07
Show Gist options
  • Save khayyamsaleem/15647cf024218fe10c519f1c1aa32423 to your computer and use it in GitHub Desktop.
Save khayyamsaleem/15647cf024218fe10c519f1c1aa32423 to your computer and use it in GitHub Desktop.
"""Python is especially useful for doing math and can be used to automate many calculations. In this project, you'll create a calculator than can compute the area of a given shape, as selected by the user. The calculator will be able to determine the area of the following shapes:"""
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "Calculator is starting"
print "Current time: %s/%s/%s %s:%s:%s:" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
sleep(1)
hint = "Don't forget to include the correct units! \nExiting..."
option = raw_input("Enter 'C' for Circle or 'T' for Triangle: ")
option = option.upper()
if option == 'C':
radius = float(raw_input("Enter radius: "))
area = pi * radius ** 2
print "the pie is baking..."
sleep(1)
print ("Area: %.2f. \n%s" % (area, hint))
elif option == 'T':
base = float(raw_input("Enter base: "))
height = float(raw_input("Enter height: "))
area = base * height * 0.5
print "Uni Bi Tri..."
sleep(1)
print ("Area: %.2f. \n%s" % (area, hint))
else:
print "Error! Invalid shape selector specified. Exiting."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment