-
Book Overview & Buying
-
Table Of Contents
Machine Learning For Dummies
By :
Computer applications aren’t very useful if they perform precisely the same tasks the same number of times every time you run them. Yes, they can perform useful work, but life seldom offers situations in which conditions remain the same. To accommodate changing conditions, applications must make decisions and perform tasks a variable number of times. Conditional and loop statements let applications perform this task, as described in the sections that follow.
Making decisions using the if statement
You use if statements regularly in everyday life. For example, you may say to yourself, “If it’s Wednesday, I’ll eat tuna salad for lunch.” The Python if statement is a little less verbose, but it follows precisely the same pattern. To see how this works, open a copy of IPython and type the following code:
def TestValue(Value):
if Value == 5:
print('Value equals 5!')
elif Value == 6:
print...
Change the font size
Change margin width
Change background colour