[Python Basics] 15.Лица на фигури. Лекция 24/05/17
не успявам да закръгля до 3 цифра след десетичната запетая.
дава ми 50/100 точки
import math
figure = str(input())
if figure == 'square':
a = float(input())
print(round((a * a), 3))
elif figure == 'rectangle':
a = float(input())
b = float(input())
print(round((a*b), 3))
elif figure == 'circle':
r = float(input())
print(round((math.pi * r * r), 3))
elif figure == 'triangle':
a = float(input())
h = float(input())
print(round(((a*h) / 2), 3))
Благодаря ти, по-принцип работи. Но уви джъдж системата не го приема като вярно, а като го рънна от програмата работи.
File "C:\Users\Administrator\AppData\Local\Temp\tmp7AAE.tmp", line 5 print(f"{(a * a):.3f}") ^ SyntaxError: invalid syntaxЗаповядай колега , 100/100 в джъдж :
import math figure = str(input()) if figure == 'square': a = float(input()) s = a * a print("{:.3f}".format(s)) elif figure == 'rectangle': a = float(input()) b = float(input()) s = a * b print("{:.3f}".format(s)) elif figure == 'circle': r = float(input()) s = math.pi * r * r print("{:.3f}".format(s)) elif figure == 'triangle': a = float(input()) h = float(input()) s = a * h / 2 print("{:.3f}".format(s))