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"
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
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.
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
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]
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.
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.