ª If Zai’s answer is correct, add one point to his score.
ª If he got hit, close the program.
Programs check (do a test) to see if a certain condition is true or not. In the first example above, the condition is “got the right answer.” Python has only a few ways to test something, and there are only two possible answers for each test: true or false. Look at this example.

Notice that in the ‘if statement’, there are two equal signs. “=” means assigning, while “==” means checking. Also, don’t forget to put colon after the statement or else it will now work. Aside from if and else, you can also use elif. It means else + if. It is usually used in conditions under conditions.
No comments:
Post a Comment