Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 22, 2017 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/a85694379fd402de0db608aa0fb69cc0 to your computer and use it in GitHub Desktop.
Save codecademydev/a85694379fd402de0db608aa0fb69cc0 to your computer and use it in GitHub Desktop.
Codecademy export
"""We are prompting a user to select either a circle or a triangle so that our calculator can determine the area of the selected shape"""
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "The calculator is starting now!"
print "The current time is: %s%s%s %s%s" % (now.moth, 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 = 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 = (0.5)*base*height
print "Uni Bi Tri..."
sleep(1)
print ("Area: &.2f. \n%s" % (area,hint))
else:
print "You entered garbage and the program will exit!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment