Teaching London Computing

Similar documents
Teaching London Computing

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Teaching London Computing

Teaching London Computing

Introduction to Functional Programming

Beyond Blocks: Python Session #1

Comp Exam 1 Overview.

Name: Partner: Python Activity 9: Looping Structures: FOR Loops

CSCI 121: Anatomy of a Python Script

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

CMSC 201 Spring 2018

Introduction to Python and Programming. 1. Python is Like a Calculator. You Type Expressions. Python Computes Their Values /2 2**3 3*4+5*6

Outline. Helper Functions and Reuse. Conditionals. Evaluation Rules for cond. Design Recipe with cond. Compound Data

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Introduction to Programming

Teaching London Computing

Introduction to Python

Introduction to Python

PREPARING FOR PRELIM 1

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington

Introduction to programming using Python

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions.

Computer Science 217

Fundamentals of Programming (Python) Getting Started with Programming

Programming II (CS300)

Getting Started with Python

Module 3: Strings and Input/Output

ENGR 102 Engineering Lab I - Computation

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

Stratford School Academy Schemes of Work

Notes on Chapter 1 Variables and String

Module 8: Local and functional abstraction

GraphQuil Language Reference Manual COMS W4115

Scripting Languages. Python basics

Advanced Python. Executive Summary, Session 1

Monty Python and the Holy Grail (1975) BBM 101. Introduction to Programming I. Lecture #03 Introduction to Python and Programming, Control Flow

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Haskell through HUGS THE BASICS

C10552: Intro to Computation. Lecture 2 July 17, 2016

Objectives. In this chapter, you will:

2. Explain the difference between read(), readline(), and readlines(). Give an example of when you might use each.

Introduction to Python (All the Basic Stuff)

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

Jython. secondary. memory

Exercise: Inventing Language

Introduction to Programming

CPE Summer 2015 Exam I (150 pts) June 18, 2015

A First Look at ML. Chapter Five Modern Programming Languages, 2nd ed. 1

Introduction to programming with Python

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Lecture 2: Variables & Assignments

C++ Support Classes (Data and Variables)

CS1 Lecture 3 Jan. 18, 2019

Module 04: Lists. Topics: Lists and their methods Mutating lists Abstract list functions Readings: ThinkP 8, 10. CS116 Fall : Lists

Introduction to C Final Review Chapters 1-6 & 13

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

CSCE 110 Programming I

Teaching guide: Structured programming

At full speed with Python

python 01 September 16, 2016

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

CS1 Lecture 3 Jan. 22, 2018

Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Topic 2: Introduction to Programming

Programming with Python

Algorithm. Building blocks of algorithm

Developing Algorithms

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Very simple programming, limited exposure to assignment and variables minutes, or a full lesson with extension exercises

The Dynamic Typing Interlude

Announcements for this Lecture

Python I. Some material adapted from Upenn cmpe391 slides and other sources

CITS 4406 Problem Solving & Programming

The C++ Language. Arizona State University 1

Working with recursion. From definition to template. Readings: HtDP, sections 11, 12, 13 (Intermezzo 2).

Midterm 1 Review. Important control structures. Important things to review. Functions Loops Conditionals

Programming for Engineers in Python. Autumn

Working with recursion

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

About the Final. Saturday, 7-10pm in Science Center 101. Closed book, closed notes. Not on the final: graphics, file I/O, vim, unix

Scheme as implemented by Racket

CS 1110 Prelim 1 October 15th, 2015

Cambridge International AS & A Level Computer Science

cs1114 REVIEW of details test closed laptop period

Lecture Writing Programs. Richard E Sarkis CSC 161: The Art of Programming

Lecture #7: Recursion (and a data structure)

Chapter 2 C++ Fundamentals

CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random. Adapted from slides by Marty Stepp and Stuart Reges

CSC 148 Lecture 3. Dynamic Typing, Scoping, and Namespaces. Recursion

Play with Python: An intro to Data Science

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda

Functional abstraction

S206E Lecture 19, 5/24/2016, Python an overview

Grouping Objects. Primitive Arrays and Iteration. Produced by: Dr. Siobhán Drohan. Department of Computing and Mathematics

Chapter 5 Functions. Dr. Zhang COSC 1436 Summer, 2018 June 19, 2018

Functions and Decomposition

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Transcription:

Teaching London Computing A Level Computer Science Topic 1: GCSE Python Recap William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London

Aims What is programming? Recap GCSE Python Programming concepts Learning programming Outline the course Contents A level curricula Materials

What is Programming? What is the essence of Programming? Do we learn Python or Programming?

Problem: Largest Item Find the largest one 27 12 53 13 25 68 18 66 23 15 36 Definition: One of the numbers in the list No other number in the list is larger Programmer needs a recipe for finding it!

Problem: Largest Item Here is a recipe largest ß first item while more items in list item ß next item if item greater than largest largest ß item Not yet a program!

Programming Recipe / procedure / algorithm for solving a problem in a language understood by a computer Problem à Recipe à Program Problem solving Writing a Program

Computational Thinking... the thought processes involved in formulating problems and their solutions so that the solutions are represented in a form that can be effectively carried out by an information-processing agent Concepts algorithmic thinking: developing steps decomposition: spotting the parts of a problem abstraction: ignoring unnecessary detail generalisation: making the specific more general evaluation: how good is it?

Practical Exercises 1.1 1.3 Describe a recipe for finding the two largest items in a list

Challenge Solution Describe a recipe for finding the two largest items in a list flrgst ß max(first item, second item) slrgst ß min(first item, second item) while more items in list item ß next item if item GT slrgst if item GT flrgst slrgst ß flgrst flrgst ß item else slrgst ß item

Challenge Simpler Solution? Describe a recipe for finding the two largest items in a list largest ß largest item of list remove largest from list second largest ß largest item of new list

Programming Concepts

Language Concepts Concepts Python Example(s) Literal (Constant) 'abc' "william" 42 3.14159! Expression 2**3**4 "he"+"llo" x > 5! Assignment Sequence area = length * width! x = 7! y = x - 5! Selection if x > 5:! Loop while x < 7:! Function call Function definition print("ans=", ans)! def area(l, w):!

Python Types Python values belong to types: String Integer Floating point Boolean List Types are dynamic Try the type function There are more types! Variable are not declared, but must be initialised before they are referenced

Python Expressions Type Operators Functions/Methods Numbers + - * ** / // %! str() abs() pow()! String +! len() int()!.append().remove()!.split().count()! Boolean results Boolean operands ==!= > < >= <=! and or not! List in not in [:]! len() min() max()!

Python Library The library is a large collection of functions, methods and module E.g. random module Standard library: all Python installations Other packages: installed when needed Issue Very complex: need to guide students

Practical Exercise 2.4 Look up the standard library online; read the introduction In Chapter 2, (Built in Functions), lookup and try the bin() function the bool() function the range() function In Chapter 4 (Built in Types), lookup << operator, e.g. 10 << 2! divmod() function Behaviour of a slice with 3 arguments: [m:n:o]!

Scope What variables are available at any place? Python uses dynamic scoping: Variables added by executing an assignment Other languages are different Local versus Global scope (simplified) Local: inside a function Global: not in a function

Practical Exercise 2.5 2.6 Try the following program. Can you explain it? def printx():! print("this is x:", x)!! y = int(input("enter a num> "))! if y % 2 == 0:! x = y!! printx()!

Errors (Practical Exercise 2.7) Syntax error Letters do not form a Python program E.g. brackets do not match Name (Scope) error Using a name that is not defined E.g. Reading a variable that has not been initialised Type errors Operation not available for these types E.g. "william" "iam" Evaluation error Expression cannot be evaluated E.g. "william"[99]

Learning Programming

Axes of Learning Solving problems Writing programs Understanding programs Can predict result of program Test it: what does this program do? Writing programs Choose expressions and statements Find bugs Test it: implement / complete short program Solving problem Problem à recipe Test it: solve open problems

Deepening and Mental Models Deeper understanding Initial understanding may be useful but partial Challenge and refine Example assignment Understanding 1: assignment gives a name to expression Understanding 2: assignment overwrites an existing value in a variable (memory) Understanding 3:

Example: Understanding Assignment Assignment as naming: but what about: width = 10! height = 17! area = height * width! print(area)! numa =...! numb =...! if numa < num B:! numb = numa! numa = numb! print("the larger number is in numa")! lst = [1,3,5,7]! lst[3] = lst[1]! lst[0] = lst[0] + lst[1]! print(lst)! myfriends = ["John", "Jo"]! yourfriends = myfriends! myfriends.remove("jo")! yourfriends.append("jane")! print(myfriends)!

Practical Exercises 3.1 3.2 Explore the sequence of ideas involved in learning if statements

Problem Solving Understand problem Try example Simplify the problem Design the solution What is the input and output? Half-way techniques Pseudo code Flow charts

Software Development Do you: Just Write a Program? Lifecycle Describes the process Analyse Understand problem à specification Design Arrange parts How to design? Analyse Design Implement Test

Characteristics of a Programmer Analytical Understanding problems Think like a computer Imaginative Invent solution Design program Resilient Trying different solutions Looking for bugs

Course Aims and Overview

Topics 1. Programming and s/w development Arrays and recursion Object-oriented programming Software design techniques 2. Algorithms and data structures Sorting and searching Trees and lists 3. Computer systems Computer architecture How programs are run 4. Theory of computing Finite state machines Language syntax and processing Computational Thinking

A Level Curricula In transition: new from 2015 A2 and AS separate Questions combine topics Differences between boards Mainly looked at: OCR, AQA Details differ: themes the same

Course Materials Each session Slides Practical exercises References notes Same sections Practical work During slides After presentation Folder and web site

Summary Programs are recipes for a computer Recipe to solve a problem Program in a particular language Learning programming combines Problem solving Understanding programs Writing programs

Practical Exercises 3.3 Planning a complex program