0

I'm trying to compare 2 equations with varying variable.With the aim of finding the variable that balances the two equations.

This is what I'm battling with. any idea on how to go about it pls 🙏 import math try: import gdata.docs.service except ImportError: gdata = None def proddo(): for x in range(200): 10 * x pseudo == 500/x if proddo() == pseudo: return true print (proddo) I know this is a mess, but I need assistance

14th Feb 2020, 4:32 AM
wizHÆVÊN§
wizHÆVÊN§ - avatar
2 ответов
0
Hmm, where to start? I have no idea what your function 'proddo()' is supposed to be doing, so I can't say how to fix it as such, but there are a few errors that I have noticed. Firstly, the function will run into a NameError. The line 'pseudo == 500/x' is trying to compare the value of the variable 'psuedo' with 500/x. But 'psuedo' hasn't been defined yet, so you will get the NameError. I think you meant to do 'psuedo = 500/x' - just one '=' sign. I'll assume this is changed from now on. Secondly, the function will run into a DivisionByZero error. The for loop 'for x in range(200]' will mean that x takes each value in turn of the numbers 0 to 199, 0 first. The line 'psuedo = 500/x' will try and divide 500 by 0, resulting in the error. If you want 'x' to take the values of 1 upward, you will need to create your for loop using 'for x in range(1,200]:'. I'll assume this is changed from now on.
15th Feb 2020, 4:20 PM
Russ
Russ - avatar
0
Thirdly, your function will create an infinite recursive loop. In the line 'if proddo() == pseudo:' the proddo() part calls its own function again. Every time it is called, it creates another for loop, creates another variable 'pseudo' and calls itself again. Again I'm not sure what to suggest as I don't know what the function is meant to do. true needs to be changed to True. print(proddo) needs to be changed to print(proddo()). I don't mean to pick your code apart but all these need addressing in order to get any sort of output from it. One extra issue is the line '10 * x' just doesn't do anything. It multiplies x by 10 and then simply forgets the result - x remains the same value it was before.
15th Feb 2020, 4:28 PM
Russ
Russ - avatar