OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 3: Built-in functions.

Slides:



Advertisements
Similar presentations
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 15 Tuples 5/02/09 Python Mini-Course: Day 4 – Lesson 15 1.
Advertisements

String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Lecture 03 – Sequences of data.  At the end of this lecture, students should be able to:  Define and use functions  Import functions from modules 
Lists Introduction to Computing Science and Programming I.
Introduction to Python
Introducing the Erlang Language Why Erlang?  Exemplifies the “you can have code and concurrency that is free from side effects…there is no other way”
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 7: Program flow control.
Methods: a first introduction Two ways to make tea: 1: boil water; put teabag into cup;... etc : tell your younger brother: makeTea(1 milk, 0 sugar);
Guide to Programming with Python
Python Control of Flow.
Lecture 2 - Variables, program execution, calculations, print() COMPSCI 101 Principles of Programming.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
Introduction to Python
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 11: Writing your own functions.
Introduction to Programming Workshop 2 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
Arrays (Part 1) Computer Science Erwin High School Fall 2014.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 6: Variables and constants.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 12: A few other things.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Built-in Data Structures in Python An Introduction.
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 9: Tuples and lists.
19&20-2 Know how to declare pointer variables. Understand the & (address) and *(indirection) operators. Dynamic Memory Allocation Related Chapter: ABC.
ProgLan Python Session 4. Functions are a convenient way to divide your code into useful blocks, allowing us to: order our code, make it more readable,
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 8: Fun with strings.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
Sequencing The most simple type of program uses sequencing, a set of instructions carried out one after another. Start End Display “Computer” Display “Science”
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
INPUT & VARIABLES.
INLS 560 – F UNCTIONS Instructor: Jason Carter.
Python Let’s get started!.
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 11 Using strings and sequences 5/02/09 Python Mini-Course: Day 3 – Lesson.
Printing in Python. Printing Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Python Arithmetic Operators OperatorOperationDescription +AdditionAdd values on either side of the operator -SubtractionSubtract right hand operand from.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 10: Files.
Guide to Programming with Python Chapter Four Strings, and Tuples; for Loops: The Word Jumble Game.
GCSE COMPUTER SCIENCE Practical Programming using Python
String and Lists Dr. José M. Reyes Álamo.
Python – May 18 Quiz Relatives of the list: Tuple Dictionary Set
Python Let’s get started!.
Tuples and Lists.
Containers and Lists CIS 40 – Introduction to Programming in Python
Lesson 1 An Introduction
Introduction to C++ October 2, 2017.
String Manipulation.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Teaching London Computing
Lists in Python.
Lecture 18 Arrays and Pointer Arithmetic
Data Structures – 1D Lists
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Example 1.
CEV208 Computer Programming
String and Lists Dr. José M. Reyes Álamo.
Logical Operations In Matlab.
Lists in Python Outputting lists.
Reference semantics, variables and names
Introduction to Computer Science
CMSC201 Computer Science I for Majors Lecture 16 – Tuples
Class code for pythonroom.com cchsp2cs
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Presentation transcript:

OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 3: Built-in functions

OCR Computing GCSE © Hodder Education 2013 Slide 2 Python 3: Built-in functions A function is a package of code. It usually returns a value. Python has lots of built-in functions. They have names. They have brackets to hold any arguments passed to them. A common one is print():

OCR Computing GCSE © Hodder Education 2013 Slide 3 Python 3: Built-in functions Suppose we give the variable a the value 5 a=5 Then we type: print (a) Python outputs 5 Print(‘a’) Python outputs a The quote signs tell print() to output the letter a, not the variable.

OCR Computing GCSE © Hodder Education 2013 Slide 4 Python 3: Built-in functions The len() function This tells us the length of something. It can be a string. (a string is a sequence of characters) If we type length=len(‘hello’) Python outputs 5.

OCR Computing GCSE © Hodder Education 2013 Slide 5 Python 3: Built-in functions len() can also tell us the size of other Python objects. Later we shall see that it can tell us the number of elements in a list or a tuple. e.g. Here is a list stored in the variable movie. movie=['Skyfall','PG','26/10/2012',143] If we then print(len(movie)) Python outputs 4 because there are 4 items in the list. We can embed functions in each other. Notice that the len() function is embedded in the print() function.

OCR Computing GCSE © Hodder Education 2013 Slide 6 Python 3: Built-in functions Another function: sorted() You can see all the built-in functions at: