蟒蛇(4天)神秘错误的新成员


from __future__ import division
import decimal
print "Type the total population"
a = float (raw_input())#population
print "type the number of seats"
b = raw_input()#seats
d = int(a) / int(b)
print "The Devisor is:",
print d
print "Type state population"
s = float (raw_input())
one = int(s) / int(d)
print "States  standard quota is:",
print one
print "Type next states population"
s = float (raw_input())
two = int(s) / int(d)
print "States  standard quota is:",
print two

print "Type next states population"
s = float (raw_input())
three = int(s) / int(d)
print "States  standard quota is:",
print three
print "Type next states population"
s = float (raw_input())
four = int(s) / int(d)
print "States  standard quota is:",
print four
print "Type next states population"
s = float (raw_input())
five = int(s) / int(d)
print "States  standard quota is:",
print five
print "list of states standard quotas"
print one
print two
print three
print four
print five
x = int(one) + int(two) + int(three) + int(four) + int(five)
print "type decimals one at a time"
e = float (raw_input())
f = raw_input()
g = raw_input()
h = raw_input()
i = raw_input()
z = int(e) + int(f) + int(g) + int(h) + int(i) # This is where error is
print "distribute following from highest to lowest decimal"
print int(z)

raw_input("按任意键继续:")

在此处输入代码

----- 这是我为汉密尔顿在国会中分配代表权的方法制作的计算器代码,它将节省我在数学上的时间,它给了我一些我真正关心的东西来练习。一切都很好,直到我评论 #error 这一点。通常我会在 IDLE python shell 中进行测试,但由于raw_inports中需要输入,它不起作用。请记住,我对python很陌生,所以我知道我的代码很可能效率低下。此外,如果没有发生错误,我就会遇到结果 0 的问题,这应该是所有小数加起来,等于 1 到 3 之间的小数(通常)

由于您使用的是浮点数,因此必须使用 float 而不是 int 将用户输入转换为数字:

z = float(e) + float(f) + float(g) + float(h) + float(i)

最新更新