Skip to content

Instantly share code, notes, and snippets.

@khayyamsaleem
Created August 17, 2017 18:52
Show Gist options
  • Save khayyamsaleem/8df607859a0b9e68d4d2d4b5b60ead7a to your computer and use it in GitHub Desktop.
Save khayyamsaleem/8df607859a0b9e68d4d2d4b5b60ead7a to your computer and use it in GitHub Desktop.
# help user calculate area of shapes
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "calculator is starting up"
print ('%s/%s/%s %s:%s') % (now.month , now.day , now.year , now.hour , now.minute)
sleep(1)
hint = "Don't forget to include the correct units!\nExiting"
option = raw_input("enter C for Circle or T for Triangle: ")
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 = 1/2 * base * height
print "Uni Bi Tri..."
print ("Area: %2f. \n%s" % (area, hint))
else:
print "user entered garbage , program will exit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment