gpt4 book ai didi

python - 如何将一个数字除以索引中的一个数字?

转载 作者:行者123 更新时间:2023-12-01 00:21:35 25 4
gpt4 key购买 nike

我的程序应该回答 ax = b 形式的方程

    a = input("What is the part with the variable? ")
b = input("What is the answer? ")
print('the equation is', a , '=', b)
letter = a[-1]
number = a[0:-1]
answer = b /= number
print(letter,"=",answer)

在第 6 行中,我收到无效语法错误。如何回答这个方程?

最佳答案

a = input("What is the part with the variable? ")
b = input("What is the answer? ")
print('the equation is', a , '=', b)
letter = a[-1]
number = a[0:-1]
answer =float(b)/float(number)
print(letter,"=",answer)

What is the part with the variable? 25c

What is the answer? 8

the equation is 25c = 8

c = 0.32

关于python - 如何将一个数字除以索引中的一个数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58921638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com