Python, Area Calculator


Hi, I'm stuck with Area Calculator in Python. When the program runs and asks me to type "C" or "T", I type "c" in order to check whether my .upper function works, but it keeps telling me "NameError: name "c" is not defined". But I'm not supposed to define lowercase "c" because it must automatically be changed to uppercase. What's wrong? Thank you!

Replace this line with your code. 
"""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:

The program should do the following:

Prompt the user to select a shape
Depending on the shape the user selects, calculate the area of that shape
Print the area of that shape to the user"""

from math import pi
from time import sleep
from datetime import datetime

now =
#Shows current time

print ("The program is running")

print ("Current time: %s/%s/%s %s:%s" % (now.month,, now.year, now.hour, now.minute))

#Sleeps the program for 1 sec

hint = "Don't forget to include the correct units! \nExiting..."

option = input("Enter C for Circle or T for Triangle: ")
option = option.upper()
#Changes lowercase to uppercase

if option == "C":
  radius = float(input("Enter the radius: "))
  area = pi * radius ** 2
  print ("The pie is baking...")
  print ("%.2f" % (area) + "\n%s" % (hint))
  #Prints the area and hint

elif option == "T":
  base = float(input("Enter the base: "))
  height = float(input("Enter the height: "))
  area = (base * height) / 2
  print ("Uni Bi Tri...")
  print ("Area: %.2f" % (area) /nhint)
  #Prints the area and hint
  print ("You entered garbage, I'm quitting!")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.