Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decisions In today’s lesson we will look at:

Similar presentations


Presentation on theme: "Decisions In today’s lesson we will look at:"— Presentation transcript:

1 Decisions In today’s lesson we will look at:
what we mean by a decision the sorts of decisions a program might need to take programming a decision in Python

2 Decisions We need to make decisions all the time – what time to get up, what to eat, how to start your essay, etc. In programming, the word decision has the same sort of meaning. Can you think of a program that does exactly the same thing every time? Most programs make some sort of decision

3 Decisions What sort of things will your program make decisions based on? Your program might need to react to: what the user does what happens in the program the values of particular variables an external factor, such as date or time

4 Programming Decisions
Most programming languages – and even spreadsheets – use an if command to make a decision In Python, the format is: if [test condition]: [command] For example... if x > 10: print(“X is bigger than 10”)

5 Multiple Commands There is an expanded form of IF that allows you to do more than one thing: if a > b: a = a + b b = a – b a = a – b print(“Always done”)

6 Alternatives You can also use the ELSE command to give an alternative:
if a > 10: print(“a is bigger than 10”) else: print(“a isn’t bigger than 10”) print(“Always done”)


Download ppt "Decisions In today’s lesson we will look at:"

Similar presentations


Ads by Google