所以我的代码看起来像这样,带有注释:
import math
#I want to do this : If the figure is a triangle it's side , noted with l = r(Stands for radius) square root 3
#another thing(Which I don't know how to spell in english) , noted with a = r/2 , it's area based on the side(noted with Al)
# = (l**2*Square root of 3) / 4 and it's area based on the radius = (3r**2*Square root of 3)/4
#My problem is that I want to keep the square root of 3 as a number without .07214214312412etc. and if it isn't a perfect
#square keep it like root3 , or something like that if it's possible
figure = input("What is the figure?")
figure = figure.lower()
r = int(input("What is the radius?"))
if figure == "triangle" :
l = str(r) + " Square root of 3"
a = int(r) / 2
l = float(l)
Al = str((l**2/4)) + " Square root of 3"
Ar = str(3*r**2/4) + " Square root of 3"
答案 0 :(得分:0)
获取字符串float()
的{{1}}是荒谬的。我想你正在尝试使用平方根符号,然后我认为你必须使用sympy库,你的代码如下:
" Square root of 3"
如果您想将其用作字符串,就像在代码中一样,您可以像这样使用
from sympy import *
figure = input("What is the figure?")
figure = figure.lower()
r = int(input("What is the radius?"))
x=sqrt(3)
if figure == "triangle" :
l=r*x
a = float(r) / 2
Al = (l**2/4)*x
Ar = (3*r**2/4)*x
答案 1 :(得分:0)
我可能会对你在这里得到的东西感到困惑 - 你是说你只想基本上做什么
en:
activerecord:
errors:
models:
my_model:
attributes:
whatever:
inclusion: "Please select whatever." # see default key: "inclusion"
或其他什么?