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

Slides:



Advertisements
Similar presentations
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Advertisements

PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
General Programming Introduction to Computing Science and Programming I.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Python From the book “Think Python”
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Errors “Computer says no..”. Types of Errors Many different types of errors new ones are being invented every day by industrious programming students..
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
End of the beginning Let’s wrap up some details and be sure we are all on the same page Good way to make friends and be popular.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Few More Math Operators
JavaScript: Conditionals contd.
BIT116: Scripting Lecture 05
FOP: Multi-Screen Apps
Fundamentals of Programming I Overview of Programming
Introducing Python Introduction to Python.
Development Environment
Introduction to Computing Science and Programming I
CMPT 120 Topic: Python’s building blocks -> More Statements
Whatcha doin'? Aims: To start using Python. To understand loops.
ME 142 Engineering Computation I
A Playful Introduction to Programming by Jason R. Briggs
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Introduction to Python
Introduction to Python
Lesson 1 An Introduction
Variables, Expressions, and IO
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Cracking the Coding Interview
Selection CIS 40 – Introduction to Programming in Python
Learning to Program in Python
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Number and String Operations
Learning Outcomes –Lesson 4
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Teaching London Computing
Introduction to TouchDevelop
Hello World! Syntax.
Coding Concepts (Standards and Testing)
Programming Errors Key Revision Points.
Programming.
Algorithm and Ambiguity
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
An Introduction to Debugging
Relations And Functions © 2002 by Shawna Haider.
Relations And Functions.
Beginning Python Programming
Chapter 1: Programming Basics, Python History and Program Components
Learning Intention I will learn about the different types of programming errors.
Programming In.
Introduction to Python
Introduction to Python programming for KS3
Review of Previous Lesson
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
WJEC GCSE Computer Science
Presentation transcript:

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

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.

Peter Vesterbacka – Co-Creator of Angry Birds

Angry Birds wasn’t developed in a day ….

Everybody has to start Somewhere 

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).

The Python Shell

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

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

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

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.

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

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

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 ….”

Creating a Chatbot!

Step 1

Step 2 Open a new Window !

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!")

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!

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

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!

See what more you can learn! http://www.codecademy.com/ Click on “LEARN” Select Python! See what more you can learn!

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

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.

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.

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

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!

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 ….

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.

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!

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?!?!"

What type of Error? SYNTAX

What type of Error? LOGIC Example Source: http://www.homeandlearn.co.uk

What type of Error? RUNTIME Example Source: http://www.homeandlearn.co.uk

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!

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!

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

End of Lesson 2