如何计算 2 个数字和 return 约 1000 个数字的等效列表的比率?
How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 numbers?
我在这个惊人的网站上在线查看等效比率。我很想模仿或做与 python 中的输出相同的事情,但这有点超出我的技能范围。
你能帮我把它写成这种格式吗,这是 python 中输出的前 3 对的样子,如果你能帮帮我好吗?我正在使用 python37
1:5618 2:11236 3:16854
这是满足我要求的网站:
https://goodcalculators.com/ratio-calculator/
到目前为止,这是我的代码,但我希望有人能帮助我,以便它以一种漂亮的花式格式打印出来,或者只是一个很酷的等比格式的数字列表:
它抛出一个错误,我不知道为什么,这是错误:
ValueError:以 10 为底的 int() 无效文字:'输入第一个数字进行比率计算:'
while True:
a = input(int(' Enter 1st number for ratio calculation: '))
b = input(int(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
你的整数应该是第一个:
while True:
a = int(input(' Enter 1st number for ratio calculation: '))
b = int(input(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
对于计算器,您可以这样做:
list_numbers={}
ratio1 = 1
ratio2 = 3698
for x in range(1,100):
list_numbers.update({ratio1*x: ratio2*x})
根据您系统上的 python 版本,有两个函数。
Python3 有 input(),python2 有 raw_input(),其中 returns 只有字符串对象 。因此您需要将其显式转换为整数。对于 python3,您可以执行以下操作,对于 python2,您可以在 raw_input() 之前使用 eval() 函数,以便计算表达式。
while True:
a = int(input(' Enter 1st number for ratio calculation: '))
b = int(input(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
Python2:
x=1
print eval('x+1') ==> 2
我在这个惊人的网站上在线查看等效比率。我很想模仿或做与 python 中的输出相同的事情,但这有点超出我的技能范围。
你能帮我把它写成这种格式吗,这是 python 中输出的前 3 对的样子,如果你能帮帮我好吗?我正在使用 python37
1:5618 2:11236 3:16854
这是满足我要求的网站: https://goodcalculators.com/ratio-calculator/
到目前为止,这是我的代码,但我希望有人能帮助我,以便它以一种漂亮的花式格式打印出来,或者只是一个很酷的等比格式的数字列表:
它抛出一个错误,我不知道为什么,这是错误:
ValueError:以 10 为底的 int() 无效文字:'输入第一个数字进行比率计算:'
while True:
a = input(int(' Enter 1st number for ratio calculation: '))
b = input(int(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
你的整数应该是第一个:
while True:
a = int(input(' Enter 1st number for ratio calculation: '))
b = int(input(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
对于计算器,您可以这样做:
list_numbers={}
ratio1 = 1
ratio2 = 3698
for x in range(1,100):
list_numbers.update({ratio1*x: ratio2*x})
根据您系统上的 python 版本,有两个函数。 Python3 有 input(),python2 有 raw_input(),其中 returns 只有字符串对象 。因此您需要将其显式转换为整数。对于 python3,您可以执行以下操作,对于 python2,您可以在 raw_input() 之前使用 eval() 函数,以便计算表达式。
while True:
a = int(input(' Enter 1st number for ratio calculation: '))
b = int(input(' Enter 2nd number for ratio calculation: '))
r = ( a/b and b/b)
print(r)
Python2:
x=1
print eval('x+1') ==> 2