Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 2 Get Started with Python – Post-Installation – Use the GUI.

Similar presentations


Presentation on theme: "Lesson 2 Get Started with Python – Post-Installation – Use the GUI."— Presentation transcript:

1 Lesson 2 Get Started with Python – Post-Installation – Use the GUI

2 Can I make a game now? values, operators, expressions, and variables.
Not yet! Basic programming concepts must come first. These concepts are: values, operators, expressions, and variables.

3 Peter Vesterbacka – Co-Creator of Angry Birds

4 Angry Birds wasn’t developed in a day ….

5 Everybody has to start Somewhere 

6 So let’s get Started With Python
Assuming you are working in Windows, you should be able to run Python by choosing: Start, Programs, Python 3.1, IDLE (Python GUI).

7

8 The Python Shell

9 Printing things to the Screen in Python
Print (‘Hello I wish to print this to the screen’)

10 In computer science, the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.  Correct Syntax Correct Syntax

11 Doing rather basic Maths Things in the Shell
Stuff like  2+2 = 4

12 Using the Shell like a Calculator!
Notice the space here didn’t make much of a difference Yeah – that can’t happen, even in Python.

13 Math Operators in Python
A list of math operators in Python. addition subtraction 47 * 2 multiplication 47 / 2 division

14 Expressions Expressions are made up of values (the numbers) connected by operators (the math signs)

15 Sounding Clever When a computer solves the expression 3 + 5 and gets the value 8, if we want to sound clever we say it has evaluated the expression. Evaluating an expression is basically reducnig the expression to a single value So, don’t say: “1+1 is 2 duh!” …say “The expression 1+1 evaluates to the value 2 ….”

16 Creating a Chatbot!

17 Step 1

18 Step 2 Open a new Window !

19 Step 3 Type this code in! If you’re lazy, cut and paste the below code. If you’re lazy, Cut and paste question = "What did you have for lunch?" print (question) answer = input() print ("You had " + answer + "! That sounds delicious!")

20 Save the file, and as long as it ends with .py
Step 4 Click File – Save as. Save the file, and as long as it ends with .py It will work okay!

21 Run the program and test it to see if it works!
Step 5 Run the program and test it to see if it works!

22 CHALLENGE: THINK! Be Creative!
Using the given code and analysing how it works, are you able to ask more questions and get more answers, and thus create your own chatbot? Be Creative!

23 See what more you can learn!
Click on “LEARN” Select Python! See what more you can learn!

24 And back to Errors for a while….
Let’s look at the types of Errors in Programming and what they are -

25 What was the last mistake you made?
We all make mistakes …. Sometimes we say or do the wrong things…. Other times, our thinking (or logic) is flawed which leads to incorrect conclusions. And we all know that when we don’t follow good advice, bad things tend to happen. Mistakes are part of life …. But following instructions (or good laws) can help minimise them.

26 In the human body, pain acts as a warning signal when something is wrong.
Put your hand in a flame and the pain will send a signal to your brain making you instantly pull away.

27 In a disease called Leprosy, the patients cease to feel pain, so their limbs waste away and get damaged. Warning signals are important! In computing language we call this VALIDATION Validation messages can pop us to tell us when we’ve made a mistake. Image: the hands of a leprosy victim

28 Warning signals or helpful warnings to VALIDATE data in Computing
Validation = ensuring that all the data entered into the system is VALID It doesn’t have to be “correct” but must be valid. Restricting options are a type of validation as the user is stopped from making a mistake!

29 Errors in Programming Types of Errors Syntax Errors Run Time errors
Logic Errors As a programmer – you may come across the above types of errors. They are errors of different types and are usually a result of mistakes that have been made. Mistakes or errors occur when someone hasn’t been careful to follow the RULES of the language they are using ….

30 Syntax Error I green the monkey. The following sentence:
Is grammatically wrong or has what we call a syntax error. "Green" is an adjective, not a verb. Errors like this (or even misspellings) can’t be understood. They are nonsense! Similarly, if you enter a VB statement that the compiler cannot understand, you have committed a syntax error.

31 Run time Error Run time errors are detected while the program executes. They’re the ones that CRASH your program These are often discovered when the user enters illegal data. For example, if the user types in a string when the computer expects a number, there will be a runtime error. Runtime errors can be tricky to track down. These errors occur when the programme is running. A simple way to crash a programme is to try to divide by zero!

32 Logic Error Syntax errors are errors of grammar; whereas, logical or semantic errors are errors of meaning. These can be thought of as coding errors. Coding errors that YOU make. They can be quite difficult to track down, and have you pretty annoyed. You will often hear yourself saying “It should work! Why won't it?!?!"

33 What type of Error? SYNTAX

34 What type of Error? LOGIC
Example Source:

35 What type of Error? RUNTIME
Example Source:

36 Heard of Ludwig Wittgenstein?
The Tractatus Logico-Philosophicus In the Tractatus, Wittgenstein attempts to acquire an understanding of how language works. He believes that before we attempt to solve the problems of philosophy, we must first understand our use of language, and how it relates to the world we observe Considered among the greatest philosophers of the century. He studied the problems and limitations of language!

37 A lot of Great Computer Scientists …
…were also Great Philosophers Take the Great CHARLES BABBAGE (inventor of the first analytical engine) He pontificated a lot about the nature of the universe In some writings, he wrote of “God” as the supreme programmer – and suggested the world we live in may just be a program!

38 We’ll be looking at Variables (how to implement these in Python) next …

39 End of Lesson 2


Download ppt "Lesson 2 Get Started with Python – Post-Installation – Use the GUI."

Similar presentations


Ads by Google