By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,596 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,596 IT Pros & Developers. It's quick & easy.

Variables

P: n/a
To All:

Folks, I need your help. I have a friend who claims that if I write:

foo = 5

then foo is NOT a variable, necessarily. If you guys can define for me
what a variable is and what qualifications you have to back you, I can
pass this along to, hopefully, convince him that foo is indeed a variable.

Thanks all!

Richard B.
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Richard Blackwood wrote:
To All:

Folks, I need your help. I have a friend who claims that if I write:

foo = 5

then foo is NOT a variable, necessarily. If you guys can define for me
what a variable is and what qualifications you have to back you, I can
pass this along to, hopefully, convince him that foo is indeed a variable.

Thanks all!

Richard B.


For example in physics formula for falling object distance:
d = (1/2)*g*t^2

In physics (math) d and t are variables and g is a constant. When you
start to calculate the distance you assign some values to the variables,
you cant touch the constant - thats the meaning of something being
constant. Or is g constant or variable?

Math:
For example if we want to visualize the speed of the object from 0 to 10
seconds we need to calculate some values to d/t graph. You do this:
t = 0, calculate d
t = 1, calculate d
....
t = 10, ...

In math you maybe call that t and d are constants, but those are
constants only for one calculation.

Programming:
In python we'd do:
---
g = 9.81
for t in range(0, 11):
d = 0.5 * 9.81 * t
print 't=%s d=%s' %(t, d)
---
it prints out:
0: 0.0
1: 4.905
2: 9.81
3: 14.715
4: 19.62
5: 24.525
6: 29.43
7: 34.335
8: 39.24
9: 44.145
10: 49.05

Constant is "variable which value is same through the program
execution", variable value can change. Knowing value of variable doesn't
make it constant.

Vocabulary and notation varies. Electric engineers might talk about
generator, in candyshop there are surely lots of wrappers, and both
soldiers and surgeons plan and execute operations.

HTH
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.