Confused with programming...
Started by
Cr4X
, Jun 02 2003 02:27 PM
10 replies to this topic
#1
Posted 02 June 2003 - 02:27 PM
I am working with the simple programming langue Python. Duh i have some problems understanding the difference between = and ==, * and ** etc. What is the difference?
Thanks in advance.
Thanks in advance.
#2
Posted 02 June 2003 - 02:37 PM
= is the asignment operator, as in "foo = bar" means "foo equals bar", and == is a comparison operator, as in "foo == bar" means "foo is equal to bar", and if the one to use in if-then statments and such.. the first simple tells the computer to take one value either form a varible or raw value and stick it into the var, the second is used to test if they are equal.
You get this in other languages as well, like in C, C++ and the like.
That help you at all?
You get this in other languages as well, like in C, C++ and the like.
That help you at all?
#3
Posted 02 June 2003 - 02:41 PM
* is multiply. ** raises a number to a power
#4
Posted 02 June 2003 - 03:42 PM
So foo = bar means just the same as
height = input("Please enter the height: ") and foo == bar is the same as 2+2==4?
#5
Posted 02 June 2003 - 06:41 PM
Correct, The following C code should provide another example
int foo = 2 + 2;
int bar = 4;
if (foo == bar){
printf("foo is equal to bar\n");
}
else{
printf("foo is not equal to bar, and your computer is f*cked.");
}
#6
Posted 03 June 2003 - 03:46 PM
Thanks a lot for your help
#7
Posted 03 June 2003 - 07:18 PM
Hey! Cr4x, When U think U have python down go and get a account on Google and play with their api's. Have fun
#8
Posted 04 June 2003 - 01:01 AM
nb, Just glad I could help.
#9
Posted 06 June 2003 - 08:29 AM
some source code form another thread removed for space and relevance.
*cough cough*
edit by StankDawg: hated to do it, but please try to keep topics organized within their respectiv ethreads unless you can tie it into another thread.
#10
Posted 06 June 2003 - 12:16 PM
Fluxx, Thats off-topic and has noting to do with the thread... The only thing remotly having to so with the current thread is that code was done for educational reasons only.. Its clear you have a problem with it however so why dont you pm me and we can talk aboutit.
Stankdawg, Any mod, please edit that.. it has nothing to do with the topic at hand.
Stankdawg, Any mod, please edit that.. it has nothing to do with the topic at hand.
#11
Posted 06 June 2003 - 12:39 PM
hmmm... well, it does deal with the topic at hand since it demonstrates the differences in the two operands in question...
I don't like to edit a lot, because I beleive in free speech. However, I will edit it for the sake of maintenance of the boards.
I don't like to edit a lot, because I beleive in free speech. However, I will edit it for the sake of maintenance of the boards.
BinRev is hosted by the great people at Lunarpages!












