0

can we declare system variables in phyton? like 2xy+3x in which x doest have value.

29th Sep 2019, 10:10 AM
amarendra
amarendra - avatar
6 Respostas
+ 9
No we cannot do that since it will raise an error showing “variable x is not defined”. This is according to Python. I dont know about other languages.
29th Sep 2019, 10:13 AM
Mohamed Arshad
Mohamed Arshad - avatar
+ 1
OOP would help a lot.
29th Sep 2019, 11:27 AM
Seb TheS
Seb TheS - avatar
0
thank you bro .then how can i sove equations in mathematics .if we want to calculate the values of a equation .and also teach me how to get an input from uiser which contains both integers and characters .example :3x^2+6x-7
29th Sep 2019, 10:54 AM
amarendra
amarendra - avatar
0
You need to program code to read strings such as "3x^²+6x-7" to do what you wanted them to do.
29th Sep 2019, 11:14 AM
Seb TheS
Seb TheS - avatar
0
want to treat 3 as integer and x ^2 as string
29th Sep 2019, 11:17 AM
amarendra
amarendra - avatar
0
You would make a list of lists, where: "3x^2+6x-7" would be converted to: [["x", 3, 2], ["x", 6, 1], [None, -7, 1] where "x", "x" and None represent var names, 3, 6, -7 represent var multipliers and 2, 1 and 1 represent exponent. Or something similar.
29th Sep 2019, 11:27 AM
Seb TheS
Seb TheS - avatar