GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing pythonprogramming.net — Python Programming Tutorials If Statement Python TutorialThe if statement is one of the most basic forms of logic that can be introduced into your program. The idea of the if statement is to assess whether something is the case, and, if it is, then to perform the following block of code within the statement. Here is an example of an if statement: x = 5
y = 10
if x > y:
print('x is greater than y')
Here, we define the variables x and y. Then, we ask if x is greater than y. If it is, then we will print 'x is greater than y.' If it is not, then nothing will happen. In this case, 5 is not greater than 10, so nothing will happen. x = 5
y = 10
if x < y:
print('x is less than y')
Now, we've flipped the comparison operator, to say if x is less than y. Basically, if 5 is less than 10. In this case, the statement is true, and the output will be 'x is less than y.' There exists 2 quiz/question(s) for this tutorial. for access to these, video downloads, and no ads.
|
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |