是否有一种方法可以更改列表中不同变量方程的值?
g_combine = [g1**4, g1**3*g2, g1**2 * g2**2, g1 * g2**3, g2**4]
def get_combine(g_combine, g1, g2):
return g_combine
例如,如果我让用户输入带有两个变量的给定公式G_combine的变量列表,我是否可以将用户输入的变量插入G_combine中,并根据G_Combine的公式获取输出列表的值?例如,如果g1 = 1,g2 = 0,我如何获得[1,0,... 0]的输出,
我试图说明用户输入所有G_combine,g1和g2,是否有一种方法首先,让基于G1和G2的所需列表在不知道该公式的情况下输出所需的列表吗?谢谢!
g_combine = [g1**4, g1**3*g2, g1**2 * g2**2, g1 * g2**3, g2**4]
def get_combine(g_combine, g1, g2):
return g_combine
for example, if i let user input a list of variables with the given formula g_combine of two variables, is there a way i can plug in the user inputted variables into g_combine and get the values of the output list based on the formula of g_combine? for example, if g1=1, g2=0, how do i get the output of [1, 0, ...0]
I was trying to say if user inputs all g_combine, g1, and g2, is there a way to let output the desired list based on g1 and g2 without me knowing the formula at the first place? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将每个列表元素作为字符串传递,则可以执行这样的操作:
输出:
If you pass each list element as string, you can do something like this:
Output: