Is there a way to program "not" or "false"? For example, if x does not ==5:
Do mean checking if {something is not something} OR {if something is false}
i think i would mean if something is false, like the statement that x==5 is false in this example.
There is many ways to do that, it all depends on the problem at hand. For example, if i wanted to see if x is 5, i would say. if (x == 5) { //The true state //Do something } else { //The false state //DO something }
i'm working on ps1, the 1000th prime number. How do I tell the program when my division test proves false, that the number is actually prime, then it should follow the second set of parameters? I have tried the following (loosely) if a%b==0: procedure x else: procedure y When I try this, the IDLE highlights "else" and says it's an error in syntax.
The syntax of your loose example is correct.
if you wanted to see if x does not =5, and therefore is a prime number, you could say if a%b!=0: procedure y you can avoid the else clause this way, because your syntax looks correct.
*even though your syntax looks correct
what does the ! mean?
!= == not equal http://docs.python.org/library/stdtypes.html#comparisons http://dpaste.com/710249/
if x != 5
Join our real-time social learning platform and learn together with your friends!