Getting Started With Python Brendan Routledge 07865 070322.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Introduction to Python
Introduction to a Programming Environment
PROGRAMMING In. STARTER Using the internet…Find …  what does “case sensitive” mean  what a programming language is..  3 benefits of Python.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Thanks to: Dr. John S. Mallozzi Department of Computer Science 1. Introduction 2. Overview of programming in Python.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Noadswood Science,  To know the basics of Python coding and decoding Monday, September 07, 2015.
An Introduction to Textual Programming
Introduction to Python
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 2.
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
CS 127 Writing Simple Programs.  Stages involved  Analyze the problem  Understand as much as possible what is trying to be solved  Determine Specifications.
Introduction to Computational Linguistics Programming I.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Do it now activity Last term we learnt about how data is represented in a computer and about how to identify different volumes of data. How many bits in.
Python From the book “Think Python”
By the end of this session you should be able to...
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Lesson 4 Using Variables in Python – Creating a Simple ChatBot Program.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
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.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
NAME Python Programming Workbook Select a Lesson:
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Algorithms and Pseudocode
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Getting Started With Scratch Brendan Routledge
Programming In Python. Starter Using the internet… Find what a programming language is.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
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.
what is computer programming?
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Programming
Python: Experiencing IDLE, writing simple programs
GCSE COMPUTER SCIENCE Practical Programming using Python
Lesson 1 - Sequencing.
GCSE COMPUTER SCIENCE Practical Programming using Python
Key Ideas from day 1 slides
Lesson 4 - Challenges.
Lesson 1 An Introduction
Variables, Expressions, and IO
Introduction to Programmng in Python
Learning to Program in Python
Learning to Program in Python
Today’s lesson – Python next steps
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Coding Concepts (Basics)
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
A look at Python Programming Language 2018.
Introduction In today’s lesson we will look at: why Python?
Beginning Python Programming
12th Computer Science – Unit 5
Introduction to Python
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Getting Started With Python Brendan Routledge

What is Python? A widely-used programming language Focus is on code readability and syntax allows concepts to be expressed in fewer lines of code Python is used by many major organisations including NASA and YouTube It is one of the 3 programming languages which can be used to write Google Apps

The Computing Curriculum At Key Stage 1 children will understand algorithms, that programmes require precise instructions, will create and debug simple programmes, predicting how they will work and understand how technology appears in everyday life At Key Stage 2 children will design, write and debug programs, use sequence, selection, and repetition in programs, work with variables and different kinds of input, be able to correct errors in programmes and algorithms and understand how networks work At Key Stage 3 learners will understand use of key algorithms that reflect computational thinking, use 2 or more programming languages, one of which is textual, design and develop modular programs that use procedures or functions, understand simple Boolean logic and some of its uses in circuits and programming

Key Aspects What is an Algorithm? The need for Precision The importance of Prediction Essential skills of Debugging Importance of Sequencing Efficiency of Repetition/Looping Use of Variables to extend functionality

The Iterative Process of Programming PLAN Plan how your program will solve the problem PROGRAM Use your plan to write/edit your program TEST Does your program do what you wanted? DEBUG Fix any problems and improve it ANALYSE What is the problem you need to solve?

Working within the Python Shell Select ‘Idle’ to open the editor/interpreter This editor is an area to try out commands – what you write here is not saved! Try these – do they work?: print(5) Print(5) print(hello) print(‘hello world’) print(“hello world”) So ‘print’ means output something to the screen

Working within the Python Shell print(“Question: What goes clip?\nAnswer: A one legged horse”) Try this: print(“Question: What goes clip?”) then print(“A one legged horse”) then try Escape sequences are specific switches to change the way things display \n creates a return line in a string of text \t creates a tab indent in string of text \\ allows a backslash to appear in string of text \” allows speech mark to appear in string of text

Working within the Python Shell Try these – do they work?: input() input(What is your name?) input(“What is your name?”) input(‘What is your name?’) So ‘input’ means input something from keyboard

Working with variables A variable is a container which stores some data for use later or elsewhere. A variable needs a name so that it can be identified when it is used. Call your variable ‘a’ and give it a value a = 5 Ask Python what ‘a’ is by typing ‘a’ and it will return a value Variables can also be text strings – a = “hello world” So a variable is a way of storing data for use in a program

Working with variables Variables need more suitable names to identify them. myName = “Brendan” faveFood = “Fish ” type ‘myName’ – does it output the expected value of the variable? Variables should be carefully named when used in your program

Python for Maths Can use Python as a mathematical tool. Try typing Use + - * / Make this into a variable sum = Try some other calculations Python can carry out many mathematical operations

Using repetition To use repeated commands (loops) in Python is easy. number=1 while number < 101: print (number) number = number+1 Task – write a short program which counts up to 100 in 5s Python handles repetition and looping easily Was your program: number=0 while number < 101: print(number) number = number+5

Using repetition Try creating a text string which loops lines=0 while lines < 50: print (“I will not write code in Art lessons”) lines = lines+1 Try some of your own ideas Python handles repetition and looping easily

Creating and saving a program From Python Shell window, select File > New File to open new window Save your program with a new filename Write a very short program e.g. print(“Hello this is my very first program in Python”) then run it by pressing F5. Write a simple function, as follows: Start with a comment – denoted by a # at the start of the line Script could be something like: # This program will say hello to the user def main(): print(“What is your name?”) yourName = input() print(yourName) Run program – at the prompt type main()

Creating and saving a longer program From Python Shell window, select File > New File to open new window Save your program with a new filename Write a short programme which defines a function called times_tables and which allows you to see any times table. Start with: def times_tables(num): n=1 while n <= 10: print(n, "x", num, "=", n*num) n =n+1 How would you make it display a different partof a times table, say from 20 to 30?

An even longer program…. We are going to make a Number Guessing Game. Computer will think of a number and player will try to guess it Copy the code from the sheet very carefully. As you go try to figure out what each bit of the code does in the game Two new things in this script: 1.The ‘return’ keyword – tells the is_same() function what value should be sent back when it is called. As well as sending data to functions they can also return data. Here it returns the value of the variable result 2. Converting user’s input into an integer – this is done by wrapping it in int(input……). This is because anything coming from keyboard input is received as strings. So it has to be converted to a different type of data – this is called casting.

Some useful Python resources Python Scheme of Work for Upper KS2 Coding at School Python Programming Guide – Simon Haughton Python Tutorial for Schools Coding Club Learn Street