Hello. I have three problems regarding the Area-Calculator project. And I've read previous topics about This problem on the forum, without result. My three problems are:
1: programs says there is a syntax-error regarding the elif-statement. I've tried to write it in different ways, without result. I've used a second if instead of elif, which makes it impossible to calculate area of triangle, because the letter T isn't recognized.
2: Nothing but C is recognized as a valid input from user.
3: Only uppercase letters are recognized, even if .upper() is used. (I should be able to write c or t and still get valid input).
Please have A look at my code, and give feedback about how to solve the problems I have.
Best regards, AnarkoBat
"""This will be a simple program that calculates the area of a triangle, or a circle, depending on the user.""" from math import pi from time import sleep from datetime import datetime now = datetime.now() print "The calculator is now booting.." print "Current time: %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 and T for Triangle: ") option = option.upper() if option == 'C': radius = float(raw_input("What is the 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("Please enter base of triangle: ")) height = float(raw_input=("What is the height of the triangle?:")) area = 0.5*base * height print "Uni Bi Tri..." sleep(1) print ("The Area is: %s " % (area, hint)) else: print "Your entered garbage. program will exit."