Sign in to follow this  
Followers 0
Cr4X

Confused with programming...

11 posts in this topic

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.

0

Share this post


Link to post
Share on other sites

= 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?

0

Share this post


Link to post
Share on other sites

* is multiply. ** raises a number to a power

0

Share this post


Link to post
Share on other sites

So foo = bar means just the same as

height = input("Please enter the height: ")

and foo == bar is the same as 2+2==4?

0

Share this post


Link to post
Share on other sites

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.");}
0

Share this post


Link to post
Share on other sites

Hey! Cr4x, When U think U have python down go and get a account on Google and play with their api's. Have fun

0

Share this post


Link to post
Share on other sites
some source code form another thread removed for space and relevance.

*cough cough* :nono:

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0