Area Calculator Line 7, Syntax Error, Invalid Syntax


#1

I have no idea what's wrong with datetime string in Line 7. I've rewritten it a bunch of times and looked at other people's projects. To me, they all look the exact same as mine. Anyone have any ideas?

 https://gist.github.com/90883a677be1d8f145c66fa98b421a40
#Calculates the area of a given shape
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "The calculator is starting up..."
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 or T for Triangle:")
option = option.upper()
if option == "C":
    radius =float(raw_input("Enter 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("Enter the base:"))
    height = float(raw_input("Enter the height:"))
    area = (0.5) * base * height
print "Uni Bi Tri..." 
sleep(1)
print (%.2f. \n%s) % (area, hint)
else:
    print"You entered garbage! Program will now exit. Goodbye"


#2

Need a comma between these two arguments.


#3

Wow I can't believe I didnt even see that! Thank you so much for your help!


#4

Do you see anything wrong with this one Line 18, because this one has me stumped also?

elif option == "T":


#6

Check the spelling of your object on line 10.


#7

Ok i saw the colon after the word hint in Line 9, I took that out. I didn't see what was misspelled in Line 10 but i erased it and rewrote it anyways and checked it forward and backwards 10 times, so I think it's good now. But its still coming up with syntax error in Line 18 elif option == 'T': I have no idea

    #Calculates the area of a given shape
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "The calculator is starting up..."
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 or T for Triangle:")
option = option.upper()
if option == "C":
    radius =float(raw_input("Enter 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("Enter the base:"))
    height = float(raw_input("Enter the height:"))
    area = (0.5) * base * height
print "Uni Bi Tri..." 
sleep(1)
print (%.2f. \n%s) % (area, hint)
else:
    print"You entered garbage! Program will now exit. Goodbye"

#8

I may have got the line number wrong. It was the misspelling that I meant to point out.


#9

I'm stumped lol elif looks good, option looks good, T is in quotes, colon at the end right?


#10

The three lines above that one need to be indented so they are inside the if block.


#11

Wow thanks a lot, things are starting to make more sense to me now thanks for all your help


#12

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