0
How variables used in mathematics and computer programming are similar?
Comparison between variables in mathematics and variables used in programming (eg. Python).
4 Answers
+ 3
In mathematics, variable are unknown thill equation was not finally. After that, variable got a value. In programming, variables are stores memory stack for any values. Of course, variables in programming languages may contains logic operators, strings, values (float point, integers...)...
+ 2
I'm not really getting what exactly you want to know...
Variables in programming are similar to maths in the way that they are placeholders for values with which you can calculate.
a = 5
b = 10
print(a + b)
#Output: 15
print(a < b)
#Output: True
Besides this very obvious thing, what do you want to know?
+ 2
Not really. In mathematics, a variable, say, 'x' represents an abstract notion of any number, where as, in programming, 'x' refers to a concrete number somewhere in memory.
Also, variables can be set, and modified, because in programming one thing happens after another; there is a concept of time, while in mathematics, there is no concept of time.
x = x + 1 makes perfect sense in programming.
+ 1
Vlad Serbu, if you look at the parameters of a function, the degree of similarity goes up again.
def f(x):
return x*x # or whatever
So x can be filled with any value, and f will do the evaluation for what comes in.
X becomes an 'abstract' placeholder for whatever f needs for an argument.