程序设置为计算三角形的面积.三角形边(a,b,c)是输入.该代码仅适用于certian编号,而不适用于其他编号.例如
当a,b和c分别为:2,3,4代码没问题.2,3,5输出0.00这是错误的.2,3,6程序打印数学域错误
def main():
print "Program calculates the area of a triangle."
print
a, b, c = input("Enter triangle's sides length: ")
s = (a+b+c) / 2.0
area = sqrt(s*(s-a)*(s-b)*(s-c))
print "The area is %.2f" % area
main()
Run Code Online (Sandbox Code Playgroud)
你能看出什么是错的吗?
我有这种不寻常的时间格式.
t1367071200
Run Code Online (Sandbox Code Playgroud)
要么
t1367063100
Run Code Online (Sandbox Code Playgroud)
谷歌并没有多说,但他们确实说这是一个时间18:00.你有什么线索如何阅读这个字符串,以便我可以弄清楚时间吗?或者我能读到的东西因为我第一次看到这个.
鉴于这两个列表:
first = [('-2.50', '1.91', '2.03'), ('3.00', '1.83', '2.08')]
second = [(('-2.50', 0.889258, 1.069258), ('3.00', 0.931381, 1.021381))]
Run Code Online (Sandbox Code Playgroud)
这是一项双任务挑战.Firslty,在列表中second,我需要识别一个具有最大价值的元组(而位于0此处的值:-2.50并且3.00必须被忽略).然后,作为第二个任务,我们需要输出相应的元组表单列表first.所以它应该导致:
('-2.50', '1.91', '2.03')
Run Code Online (Sandbox Code Playgroud)
这是因为在第一步中找到的最大值应该1.069258是第一元组内部.
我在这里遇到的障碍是找到具有最大价值的元组(我知道我可以用它max()来找到值,但我需要整个元组),问题的第二部分我认为我只会简单地使用该if语句.
我的网站上有两个表,名称为:
<table class="table1">
<table class="table2">
Run Code Online (Sandbox Code Playgroud)
我试图引用table1's td,tr并th使用:
table.table1 td, tr, th {
border: 1px solid red;
}
Run Code Online (Sandbox Code Playgroud)
但它适用于我的两个表,我无法覆盖样式table2.什么地方出了错?
我在使用Python 2.7
我正在做一些非常基本的练习,这是我的代码:
def main():
print """Program computes the value of an investment
carried 10 years into the future"""
principal = input("Enter the principal: ")
apr = input("Provide (in decimal format) the annual percentage rate: ")
for i in range(10):
principal = principal * (1 + apr)
print "The value in 10 years will be: $", principal
main()
Run Code Online (Sandbox Code Playgroud)
代码正在运行,但我希望输出只是最终结果.我现在得到的是循环的所有10个步骤一个接一个地打印.
我该如何解决这个问题?