Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Similar documents
GE PROBLEM SOVING AND PYTHON PROGRAMMING. Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING

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

ENGR 102 Engineering Lab I - Computation

CS 234 Python Review Part 2

CPSC 3740 Programming Languages University of Lethbridge. Control Structures

Introduction to Python

Abstract Data Types. CS 234, Fall Types, Data Types Abstraction Abstract Data Types Preconditions, Postconditions ADT Examples

Structure and Interpretation of Computer Programs

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python

2.Raspberry PI: Architecture & Hardware Specifications

Flow Control: Branches and loops

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

Flow of execution! The flow of execution is the order in which program statements are executed.

Abstract Data Types Chapter 1

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala

Control Structures 1 / 17

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Introduction to Concepts in Functional Programming. CS16: Introduction to Data Structures & Algorithms Spring 2017

1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013

Module 06. Topics: Iterative structure in Python Readings: ThinkP 7. CS116 Spring : Iteration

Structure and Interpretation of Computer Programs

Variable and Data Type I

Visualize ComplexCities

CPTS 111, Fall 2011, Sections 6&7 Exam 3 Review

Play with Python: An intro to Data Science

Sets and Maps. Set Commands Set ADT Set ADT implementation Map ADT Map ADT implementation

Test #2 October 8, 2015

Shell / Python Tutorial. CS279 Autumn 2017 Rishi Bedi

Structure and Interpretation of Computer Programs

Selection Statement ( if )

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

In addition to the correct answer, you MUST show all your work in order to receive full credit.

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

Key Differences Between Python and Java

Lecture 13: Expression Evaluation

Review for the Final Exam CS 8: Introduction to Computer Science, Winter 2018 Lecture #15

[CHAPTER] 1 INTRODUCTION 1

Structure and Interpretation of Computer Programs

Module 10: Imperative Programming, Modularization, and The Future

CS 234. Module 3. September 29, CS 234 Module 3 Data structures, ADTs with no order of any kind, Python review 1 / 19

CS 1301 Exam 2 Fall 2010

All programs can be represented in terms of sequence, selection and iteration.

CS 1301 Exam 3 Fall 2014

Comp Exam 1 Overview.

Representation Invariants and Abstraction Functions

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

Lecture 11: while loops CS1068+ Introductory Programming in Python. for loop revisited. while loop. Summary. Dr Kieran T. Herley

Assignment 2. CS 234 Fall 2018 Sandy Graham. Create()

CS Final Exam Review Suggestions - Spring 2014

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

Table of Contents EVALUATION COPY

CS 61A Interpreters, Tail Calls, Macros, Streams, Iterators. Spring 2019 Guerrilla Section 5: April 20, Interpreters.

Conditionals: Making Choices

Lists, Mutability, ADTs, and Trees Spring 2019 Guerrilla Section 2: March 2, 2019 Solutions. 1 Sequences. Questions. lst = [1, 2, 3, 4, 5] lst[1:3]

CS-141 Final Exam Review December 8, 2017 Presented by the RIT Computer Science Community

Variable and Data Type I

Lists How lists are like strings

Announcements. Project 5 is on the street. Second part is essay questions for CoS teaming requirements.

Babu Madhav Institute of Information Technology, UTU 2015

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

First name (printed): a. DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

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

CS1 Lecture 3 Jan. 18, 2019

CS 2316 Exam 1 Spring 2014

CS 1301 Exam 1 Fall 2010

CS-141 Final Exam Review December 16, 2015 Presented by the RIT Computer Science Community

MEMOIZATION, RECURSIVE DATA, AND SETS

CS1 Lecture 3 Jan. 22, 2018

Module 08: Searching and Sorting Algorithms

Python. Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar. December 28, Outline

Structure and Interpretation of Computer Programs

Module 05: Types of recursion

Hacettepe University Computer Engineering Department. Programming in. BBM103 Introduction to Programming Lab 1 Week 4. Fall 2018

CSI33 Data Structures

Functions and Recursion

CS 1301 Exam 1 Fall 2010

Chapter 8. Statement-Level Control Structures

Lessons on Python Functions

Overview of List Syntax

Basic Python 3 Programming (Theory & Practical)

Practice Question. Omar Khan / Atif Alvi. October 10, 2016

Python. Objects. Geog 271 Geographic Data Analysis Fall 2010

CS 1301 Exam 1 Answers Fall 2009

Introduction to Python Programming

CSC148-Section:L0301

Python. Executive Summary

python. a presentation to the Rice University CS Club November 30, 2006 Daniel Sandler

CSI33 Data Structures

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

CPSC 217 Midterm (Python 3 version)

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

Iterative Statements. Iterative Statements: Examples. Counter-Controlled Loops. ICOM 4036 Programming Languages Statement-Level Control Structure

CS4215 Programming Language Implementation

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

Conditionals and Recursion. Python Part 4

Statements 2. a operator= b a = a operator b

Transcription:

Python review CS 234 Naomi Nishimura The sections below indicate Python material, the degree to which it will be used in the course, and various resources you can use to review the material. You are not expected to use all the resources, just the ones that suit your needs most. The course website lists additional Python resources, should you find them a preferable way to review the material. One possible way of reviewing is to try the exercises in, and then to use other resources to review any material that requires a bit more effort. If your previous exposure to Python was version 2, please see the course website for a link to a summary of differences between Python 2 and Python 3. Note: The sections below follow the order in which the material should be mastered for CS 234, not necessarily the most logical order in which to master the material if you are studying Python for the first time or are in need of extensive review. In such a case, it might be better to follow in order, reading the material on files as needed to ensure that you master the material by the dates given. 1 Python basics You will be expected to know how to create and use variables and functions, and to import modules such as the math module and modules provided for assignments. Although you will not be expected to create objects until later, at this point you should be familiar with dot notation so that you can use methods on objects. def return import (use from xx import * for a user-defined module xx.py) None Module 01: Introduction to Programming in Python Basic types and mathematical operations Calling functions Defining functions

CS 234: Python review 2 Mutation Changes in design recipe Module 1: First steps Module 2: Built-in functions Module 3: Storing and using information Module 4: Creating functions Appendix A.1 The Python Interpreter Appendix A.2 The Basics of Python Appendix A.7 User-Defined Functions 2 Program structure, input, and output 2.1 Booleans, conditionals, branching Be sure that you can write conditional expressions to allow branching in your programs. True, False ==,!=, <, >, <=, >=, if, elif, else Module 02: Making Decisions in Python Boolean expressions Conditional statements Module 5: Booleans Module 6: Branching Appendix A.4.1 Selection Constructs

CS 234: Python review 3 2.2 Iteration Iteration (while and for loops) will be used extensively in the course; be sure that you are comfortable with both concepts. while for range break continue Module 06: Iterative Structure in Python while loops for loops Module 8: Iteration using while Module 10: Iteration using for Appendix A.4.2 Repetition Constructs 2.3 Strings and user interaction We will use only basic string methods. You can look up string methods as you need them rather than investing time in reviewing them all at the beginning of the course. User interaction can come in handy in testing out your implementations, allowing you to test your code by executing various operations. Make sure to use int if needed to convert the string input into an integer. input int

CS 234: Python review 4 Module 03: Strings and Input/Output Printing to standard output Strings and their methods Reading from standard input Appendix A.5.1 Strings Appendix A.3 User Interaction 2.4 Files At times we will use files to store data items that we will add to an ADT. Be sure you can open and close a file, read and write lines, strip blank spaces, and divide an input string into a list of items (based on separation by blank spaces). open close readlines strip (string method) split (string method) Module 10: File Input and Output Appendix A.6 Text Files

CS 234: Python review 5 3 Classes We will use classes extensively in the course. You should be able to create a class, create an object, and write and use methods. class init self Module 09: Additional Options for Organizing Data Classes Module 11: Building information into objects Appendix D Classes 4 Recursion and more data types 4.1 Recursion We will use recursion, though it will not be a major emphasis of the course. Much of Module 05 of CS 116 is beyond what is needed in this course. Module 02: Making Decisions in Python Recursion Module 05: Types of Recursion Purely structural recursion Accumulative recursion

CS 234: Python review 6 Generative recursion Module 13: Recursion Appendix A.4.1 Selection Constructs 4.2 Lists Although the types of operations used in lists will be a focus of the course, we will not use lists as extensively as they were used in CS 116. You should be comfortable with the idea of methods that mutate the input and methods that do not, but you do not need to put time into extensive review of list methods. [] accessing a particular list item by index + append Module 04: Lists Lists and their methods Mutating lists Abstract list functions Module 9: Storing elements in a sequence Appendix A.5.2 Lists

CS 234: Python review 7 4.3 Tuples and dictionaries Neither tuples nor dictionaries will be used extensively in the course. [] extracting a particular list item + append Module 09: Additional Options for Organizing Data Dictionaries Module 12: Structuring data Appendix A.5.3 Tuples Appendix A.5.4 Dictionaries