About area calculator project


#1

My code is:

"""asdvfsdvgsdvgsdg"""

from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()

print "calculator is starting up"
print '%s/%s/%s' % (now.month, now.day, now.year, now.minute)
sleep(1)
hint="Don't forget to include the correct units!"
option = raw_input("Enter C for Circle or T for Triangle: ")
option = option.upper()
if option == 'C':
  radius=float(raw_input("input 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("input the height of the triangle: "))
  area = (0.5)*base*height
  print "Uni Bi Tri..."
  sleep(1)
  print ("Area: %.2f. \n%s" % (area, hint))
else:
  print "Error! Invalid shape selector specified. Exiting."

And then save and start it have a error `

File "AreaCalculator.py", line 9, in
print '%s/%s/%s' % (now.month, now.day, now.ye
ar, now.minute)
TypeError: not all arguments converted during stri
ng formatting
`


#2

Hello!

You have a small mistake in your print formatting. You are missing one of the string indicators in the print statement:

print %s/%s/%s should be print %s/%s/%s/%s

You were just missing one %s !

Hope this helps :slight_smile:


#3

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