FINAL python project HELP!

FINAL python project HELP!
0

#1
from math import pi  #This is To import the pi function
from time import sleep  #This will give some time to the code to load
from datetime import datetime  #This will Import the date and the time

now = datetime.now()

print ("Area Calculater is Staring up")

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

(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 Of the Triangle"))
  height = float(raw_input("Enter The Heigth Of The Triangle"))
  area = (0.5)*base*height
  print "Uni Bi Tri...."
  print ("Area: %.2f.\n%s" % (area, hint))
  sleep(1)
else:
    print"Error! Invalid Shape Selector Specified\n Exiting"

I get this error:


Traceback (most recent call last):
  File "python", line 25
    elif (option == ("T")):
       ^
SyntaxError: invalid syntax

IM running python version 3.6.1 idk why but for some reason my code looks off and it wont read my code can someone help me fix the errors im making this is my exact code above but its not reading it in python 3.6.1


#3

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


#4

Did you correct the code idk y I still get an error and this project is due for me today :frowning:


#5

from math import pi #This is To import the pi function
from time import sleep #This will give some time to the code to load
from datetime import datetime #This will Import the date and the time

now = datetime.now()

print (“Area Calculater is Staring up”)

print (“Current time is: %s/%s/%s %s:%s” % (now.month, now.day, now.year, now.hour, now.month))

sleep(1)

hint =“Don’t forget to include the correct units!\nExiting…”

option = input("Enter C for Circle or T for Triangle: ")

option = option.upper()

if option == “C”:
radius = float(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(input(“Enter The Base Of the Triangle”))
height = float(input(“Enter The Heigth Of The Triangle”))
area = (0.5)baseheightC

print (“Uni Bi Tri…”)
print (“Area: %.2f.\n%s” % (area, hint))
sleep(1)
else:
print(“Error! Invalid Shape Selector Specified\n Exiting”)


#6

i still get this error
Traceback (most recent call last):
File “python”, line 25
elif option == (“T”):
^
SyntaxError: invalid syntax
IDK y :confused:


#8

NOPE i still get this error my bad
Traceback (most recent call last):
File “python”, line 26
elif option == (“T”):
^
SyntaxError: invalid syntax


Plss help syntax erorr im using python 4.8.2 and i dont know what to do>>>>>
#9

Your indents are off.


#11

EDIT: thanks for help I have finished this basically i just needed to fix my code function


#12

I have got this error from respacing my work and idk what to do >…
call last):
File “python”, line 25
area = (0.5)baseheightC
^
SyntaxError: invalid syntax
[/quote]


#13

Isn’t that missing operators?


#14

Looking at your original post…

I got it to run. There were a lot of little errors. A lot of the errors involved parentheses. For example:

(sleep(1)

Why is there a starting parenthesis? Get rid of all of those. The open and close parentheses should be the same number on each line:

if option == "C"

This needs to be Option with a capital O. That easy confusion is why I would have named that variable something else. And that line needs to end in a colon.

print "Uni Bi Tri...."

I believe print is a function so you need parentheses.

When I fix all those things, it works for me.


#15

Did this run in Python 3? Because raw_input is a Python 2 object. In Python 3 it is now just input.


#16

Yes, I got it to run by converting raw_input to input - I assume the OP is using an earlier version of P.


#17
from math import pi  #This is To import the pi function
from time import sleep  #This will give some time to the code to load
from datetime import datetime  #This will Import the date and the time

now = datetime.now()

print ("Area Calculater is Staring up")

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

sleep(1)

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

option = input("Enter C for Circle or T for Triangle: ")

option = option.upper()

if (option == "C"):
    radius = float(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(input("Enter The Base Of the Triangle: "))
    height = float(input("Enter The Heigth Of The Triangle: "))
    area = (0.5)*base*height
    print ("Uni Bi Tri....")
    print ("Area: %.2f.\n%s" % (area, hint))
    sleep(1)
else:
    print("Error! Invalid Shape Selector Specified\n Exiting")

Man, your syntax needs a bit of work, you use unnecessary brackets and python 2 syntax, you forget to put colons, close brackets, use proper indentation. These projects are the basics. If you don’t fix the problems that I mentioned, you’re gonna have trouble coding. Hope the code fixes your problem and good luck coding.