Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
How to make a variable like n=1,2,3,4,5... In PY
If i/k = n I the code to know that that n can be any of the natural numbers.
4 ответов
+ 3
Your try first...
Learn about range() function to create a range of values... one simple way.
+ 3
Kreshnik Feka,
It would be very helpful if you can do a sample for us (code or pseudo code), also try to give us more details.
Thanks!
+ 1
In Python you can use the sympy library to represent expressions in symbolic algebra.
https://docs.sympy.org/latest/tutorials/intro-tutorial/intro.html#what-is-symbolic-computation
As a more general technique, you can use assertions (assert keyword) to enforce certain conditions on variable values. You can use error handling (try and except keywords) to determine what the programs should do, when the conditions are not fulfilled or an illegal operation happens. You can encapsulate your variable in a class and write validations in the __init__ method or in the property setter, to make sure that illegal values cannot be assigned.
0
you must use a 'for' loop