About area calculator project


My code is:


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)
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..."
  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..."
  print ("Area: %.2f. \n%s" % (area, hint))
  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



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:


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