Book
Week 3 - Section 0 - Those who forget the lessons of Python are doomed to repeat them :-)
Week 3 - Section 0 - Those who forget the lessons of Python are doomed to repeat them :-)
In this section we will learn about lists and tuples and we will scratch the surface of pygame. Be prepared for excitement.
Chapter 0.1 - What starts with an If, ends with a decision
Perhaps the most well-known statement type is the if statement. For example:
x = int(input("Please enter an integer: "))if x < 0:
print('Negative number')
elif x == 0:
print('Zero')
else:
print('Positive number')
Be careful of the indentation. One space character in the wrong place can damage a program of a thousand lines.
There can be zero or more elif parts, and the else part is optional. The keyword ‘elif‘ is short for ‘else if’, and is useful to avoid excessive indentation. An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other programming languages.