CSci 127: Introduction to Computer Science

Similar documents
CSci 127: Introduction to Computer Science

CSci 127: Introduction to Computer Science

CSci 127: Introduction to Computer Science

CSci 127: Introduction to Computer Science

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 3 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 3 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 2 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 1 CSci 127: Introduction to Computer Science Hunter College, City University of New York

CIS192 Python Programming. Robert Rand. August 27, 2015

Final Exam, Version 2 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Curriculum Map Grade(s): Subject: AP Computer Science

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Final Exam, Version 4 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Sample Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

Introducing: main Function, Comments, Statements

File Input/Output in Python. October 9, 2017

CMSC 201 Computer Science I for Majors

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

Problem Solving With C++ Ninth Edition

Reviewing all Topics this term

Part III Appendices 165

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

CME 193: Introduction to Scientific Python Lecture 1: Introduction

EECS 183. Week 3 - Diana Gage. www-personal.umich.edu/ ~drgage

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

Introduction to Computer Science with Python Course Syllabus

introduction (week 1)

ENGR 102 Engineering Lab I - Computation

Lecture 2. Variables & Assignment

Lecture 1. Course Overview Types & Expressions

HANDS ON DATA MINING. By Amit Somech. Workshop in Data-science, March 2016

CMPE012 Computer Engineering 12 (and Lab) Computing Systems and Assembly Language Programming. Summer 2009

CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck!

QUIZ: What value is stored in a after this

ARTIFICIAL INTELLIGENCE AND PYTHON

EECS1710. Announcements. Labtests have been returned Term Test #01 marking is in progress. Next Labtest: Thu Oct 23/Fri Oct 24

CS1 Lecture 3 Jan. 18, 2019

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

CSCI0931 Intro Comp for Humanities & Soc Sci Jun Ki Lee. Final Project. Rubric

Final Exam, Version 1 CSci 127: Introduction to Computer Science Hunter College, City University of New York

CS1 Lecture 3 Jan. 22, 2018

A. Python Crash Course

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

Boolean Expressions and if 9/14/2007

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

Lab 19: Excel Formatting, Using Conditional Formatting and Sorting Records

COMP322 - Introduction to C++ Lecture 01 - Introduction

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

PREPARING FOR PRELIM 1

Overview of List Syntax

Physics 2660: Fundamentals of Scientific Computing. Lecture 5 Instructor: Prof. Chris Neu

COURSE OF STUDY UNIT PLANNING GUIDE COMPUTER SCIENCE 1 FOR: 5 CREDITS GRADE LEVEL: 9-12 FULL-YEAR COURSE PREPARED BY: SUSIE EISEN

Control Structures 1 / 17

egrapher Language Reference Manual

Lecture 3. Functions & Modules

Matplotlib Python Plotting

Introduction to computers and Python. Matthieu Choplin

WELCOME! (download slides and.py files and follow along!) LECTURE 1

Lecture 17: Hash Tables, Maps, Finish Linked Lists

CS 115 Lecture 8. Selection: the if statement. Neil Moore

Discussion CSE 224. Week 4

Lecture 1. Types, Expressions, & Variables

CSCI-1200 Data Structures Fall 2012 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CS 115 Exam 1, Fall 2015 Thu. 09/24/2015

DEPARTMENT OF COMPUTER AND MATHEMATICAL SCIENCES UNIVERSITI TEKNOLOGI MARA CAWANGAN PULAU PINANG

61A Lecture 3. Friday, September 5

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

Decisions, Decisions, Decisions. GEEN163 Introduction to Computer Programming

Computer Science 217

Lecture 1. Course Overview, Python Basics

Key Differences Between Python and Java

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG

Python Programming, bridging course 2011

CSCI Wednesdays: 1:25-2:15 Keller Thursdays: 4:00-4:50 Akerman 211

Lecture 4: MIPS Instruction Set

Data Types and the main Function

Java Programming Basics. COMP 401, Spring 2017 Lecture 2

Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style

Computer Science II Lecture 1 Introduction and Background

nostarch.com/pfk For bulk orders, please contact us at

CIS192: Python Programming

CS/COE 1501 cs.pitt.edu/~bill/1501/ Introduction

Skills Quiz - Python Edition Solutions

CS1110 Lab 1 (Jan 27-28, 2015)

The Python interpreter

C++ for Python Programmers

COMP 2150 CS 2: Object-Oriented Programming and Data Structure Fall 2018 Dr. James Yu

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

Midterm Exam Review. CS 2420 :: Fall 2016 Molly O'Neil

CSE 240 Introduction to Computer Architecture

Project 1. due date Sunday July 8, 2018, 12:00 noon

Introduction to Python

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

Lecture 3. Strings, Functions, & Modules

You must pass the final exam to pass the course.

Transcription:

CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 1 / 48

Lecture Slip: tinyurl.com/yb8lcvl7 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 2 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! Why can t in-class quizzes taken at midnight count towards my grade? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! Why can t in-class quizzes taken at midnight count towards my grade? The in-class quizzes are in place of midterm exams. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! Why can t in-class quizzes taken at midnight count towards my grade? The in-class quizzes are in place of midterm exams. We want to know that you (and not friend/family) took the in-class quiz. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! Why can t in-class quizzes taken at midnight count towards my grade? The in-class quizzes are in place of midterm exams. We want to know that you (and not friend/family) took the in-class quiz. What s my grade in the class? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Frequently Asked Questions From lecture slips & recitation sections. Why did you reorganize the lab, 1001E? Lab serves dual purposes: recitation and drop-in tutoring. Having the teachers desk in front of the door was bad for both: It was difficult to lecture with folks walking in front of screen, and it was difficult for tutoring during quiz & lecture. Why do I need to sign in when dropping in? Our current space is temporary. We re collecting data to bolster our case for more space (& more tutors)! Why can t in-class quizzes taken at midnight count towards my grade? The in-class quizzes are in place of midterm exams. We want to know that you (and not friend/family) took the in-class quiz. What s my grade in the class? Easy estimate: 30% Programs (drop 5 lowest), 30% Quizzes (drop 2 lowest)* Of first 40: missed 8 or less, have > 90% For in-class quizzes: drop 2 (or replace 5 with final grade). CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 3 / 48

Today s Topics Recap of Python & Circuits High vs. Low-Level Programming A Simplified Machine Language Final Exam Overview CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 4 / 48

Python & Circuits Review: 10 Weeks in 10 Minutes A whirlwind tour of the semester, so far... CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 5 / 48

Week 1: print(), loops, comments, & turtles CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 6 / 48

Week 1: print(), loops, comments, & turtles Introduced comments & print(): #Name: Thomas Hunter These lines are comments #Date: September 1, 2017 (for us, not computer to read) #This program prints: Hello, World! (this one also) print("hello, World!") Prints the string Hello, World! to the screen CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 6 / 48

Week 1: print(), loops, comments, & turtles Introduced comments & print(): #Name: Thomas Hunter These lines are comments #Date: September 1, 2017 (for us, not computer to read) #This program prints: Hello, World! (this one also) print("hello, World!") Prints the string Hello, World! to the screen As well as definite loops & the turtle package: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 6 / 48

Week 2: variables, data types, more on loops & range() CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers string: sequence of characters CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers string: sequence of characters list: a sequence of items CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers string: sequence of characters list: a sequence of items e.g. [3, 1, 4, 5, 9] or [ violet, purple, indigo ] CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers string: sequence of characters list: a sequence of items e.g. [3, 1, 4, 5, 9] or [ violet, purple, indigo ] class variables: for complex objects, like turtles. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 2: variables, data types, more on loops & range() A variable is a reserved memory location for storing a value. Different kinds, or types, of values need different amounts of space: int: integer or whole numbers float: floating point or real numbers string: sequence of characters list: a sequence of items e.g. [3, 1, 4, 5, 9] or [ violet, purple, indigo ] class variables: for complex objects, like turtles. More on loops & ranges: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 7 / 48

Week 3: colors, hex, slices, numpy & images CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 8 / 48

Week 3: colors, hex, slices, numpy & images CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 8 / 48

Week 3: colors, hex, slices, numpy & images CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 8 / 48

Week 4: design problem (cropping images) & decisions CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 9 / 48

Week 4: design problem (cropping images) & decisions First: specify inputs/outputs. Input file name, output file name, upper, lower, left, right ( bounding box ) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 9 / 48

Week 4: design problem (cropping images) & decisions First: specify inputs/outputs. Input file name, output file name, upper, lower, left, right ( bounding box ) Next: write pseudocode. 1 Import numpy and pyplot. 2 Ask user for file names and dimensions for cropping. 3 Save input file to an array. 4 Copy the cropped portion to a new array. 5 Save the new array to the output file. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 9 / 48

Week 4: design problem (cropping images) & decisions First: specify inputs/outputs. Input file name, output file name, upper, lower, left, right ( bounding box ) Next: write pseudocode. 1 Import numpy and pyplot. 2 Ask user for file names and dimensions for cropping. 3 Save input file to an array. 4 Copy the cropped portion to a new array. 5 Save the new array to the output file. Next: translate to Python. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 9 / 48

Week 4: design problem (cropping images) & decisions CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 10 / 48

Week 5: logical operators, truth tables & logical circuits CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 11 / 48

Week 5: logical operators, truth tables & logical circuits in1 in2 returns: False and False False False and True False True and False False True and True True CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 11 / 48

Week 6: structured data, pandas, & more design nychistpop.csv In Lab 6 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 12 / 48

Week 6: structured data, pandas, & more design import matplotlib.pyplot as plt import pandas as pd nychistpop.csv In Lab 6 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 12 / 48

Week 6: structured data, pandas, & more design import matplotlib.pyplot as plt import pandas as pd pop = pd.read csv( nychistpop.csv,skiprows=5) nychistpop.csv In Lab 6 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 12 / 48

Week 6: structured data, pandas, & more design import matplotlib.pyplot as plt import pandas as pd pop = pd.read csv( nychistpop.csv,skiprows=5) pop.plot(x="year") plt.show() nychistpop.csv In Lab 6 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 12 / 48

Week 6: structured data, pandas, & more design import matplotlib.pyplot as plt import pandas as pd pop = pd.read csv( nychistpop.csv,skiprows=5) pop.plot(x="year") plt.show() nychistpop.csv In Lab 6 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 12 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. The opening function is often called main() CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. The opening function is often called main() You call or invoke a function by typing its name, followed by any inputs, surrounded by parenthesis: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. The opening function is often called main() You call or invoke a function by typing its name, followed by any inputs, surrounded by parenthesis: Example: print("hello", "World") CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. The opening function is often called main() You call or invoke a function by typing its name, followed by any inputs, surrounded by parenthesis: Example: print("hello", "World") Can write, or define your own functions, CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 7: functions Functions are a way to break code into pieces, that can be easily reused. Many languages require that all code must be organized with functions. The opening function is often called main() You call or invoke a function by typing its name, followed by any inputs, surrounded by parenthesis: Example: print("hello", "World") Can write, or define your own functions, which are stored, until invoked or called. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 13 / 48

Week 8: function parameters, github Functions can have input parameters. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 14 / 48

Week 8: function parameters, github Functions can have input parameters. Surrounded by parenthesis, both in the function definition, and in the function call (invocation). CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 14 / 48

Week 8: function parameters, github Functions can have input parameters. Surrounded by parenthesis, both in the function definition, and in the function call (invocation). The placeholders in the function definition: formal parameters. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 14 / 48

Week 8: function parameters, github Functions can have input parameters. Surrounded by parenthesis, both in the function definition, and in the function call (invocation). The placeholders in the function definition: formal parameters. The ones in the function call: actual parameters CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 14 / 48

Week 8: function parameters, github Functions can have input parameters. Surrounded by parenthesis, both in the function definition, and in the function call (invocation). The placeholders in the function definition: formal parameters. The ones in the function call: actual parameters Functions can also return values to where it was called. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 14 / 48

Week 8: function parameters, github Functions can have input parameters. Surrounded by parenthesis, both in the function definition, and in the function call (invocation). The placeholders in the function definition: formal parameters. The ones in the function call: actual parameters. Functions can also return values to where it was called. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 15 / 48

Week 9: top-down design, folium CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 16 / 48

Week 10: indefinite loops, searching data, random() Indefinite (while) loops allow you to repeat a block of code as long as a condition holds. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 17 / 48

Week 10: indefinite loops, searching data, random() Indefinite (while) loops allow you to repeat a block of code as long as a condition holds. Very useful for checking user input for correctness. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 17 / 48

Week 10: indefinite loops, searching data, random() Indefinite (while) loops allow you to repeat a block of code as long as a condition holds. Very useful for checking user input for correctness. Python s built-in random package has useful methods for generating random whole numbers and real numbers. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 17 / 48

Week 10: indefinite loops, searching data, random() Indefinite (while) loops allow you to repeat a block of code as long as a condition holds. Very useful for checking user input for correctness. Python s built-in random package has useful methods for generating random whole numbers and real numbers. To use, must include: import random. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 17 / 48

Python & Circuits Review: 10 Weeks in 10 Minutes Input/Output (I/O): input() and print(); pandas for CSV files Types: Primitive: int, float, bool, string; Container: lists (but not dictionaries/hashes or tuples) Objects: turtles (used but did not design our own) Loops: definite & indefinite Conditionals: if-elif-else Logical Expressions & Circuits Functions: parameters & returns Packages: Built-in: turtle, math, random Popular: numpy, matplotlib, pandas, folium CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 18 / 48

Python & Circuits Review: 10 Weeks in 10 Minutes A whirlwind tour with 10 (or so) challenges... CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 19 / 48

In Pairs or Triples: Week 1 Predict what the code will do: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 20 / 48

In Pairs or Triples: Week 2 Predict what the code will do: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 21 / 48

In Pairs or Triples: Week 3 Predict what the code will do: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 22 / 48

In Pairs or Triples: Week 4 Extend this program to also allow drawing in purple & stamping: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 23 / 48

In Pairs or Triples: Week 5 When does this circuit yield true? That is, what values for the inputs give an output value of true? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 24 / 48

In Pairs or Triples: Week 6 Predict what the following will do: print("queens:", pop["queens"].min()) print("s I:", pop["staten Island"].mean()) print("s I:", pop["staten Island"].std()) pop.plot.bar(x="year") pop.plot.scatter(x="brooklyn", y= "Total") pop["fraction"] = pop["bronx"]/pop["total"] CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 25 / 48

In Pairs or Triples: Week 7 Fill in the function body: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 26 / 48

In Pairs or Triples: Week 8 What are the formal parameters for the functions? What is the output of: r = foo([1,2,3,4]) print("return: ", r) What is the output of: r = foo([1024,512,256,128]) print("return: ", r) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 27 / 48

In Pairs or Triples: Week 9 What does this code do? CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 28 / 48

In Pairs or Triples: Week 10 Predict what the code will do: Write a function that asks a user for number after 2000 but before 2018. The function should repeatedly ask the user for a number until they enter one within the range and return the number. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 29 / 48

Python & Circuits Review: 10 Weeks in 10 Minutes Input/Output (I/O): input() and print(); pandas for CSV files Types: Primitive: int, float, bool, string; Container: lists (but not dictionaries/hashes or tuples) Objects: turtles (used but did not design our own) Loops: definite & indefinite Conditionals: if-elif-else Logical Expressions & Circuits Functions: parameters & returns Packages: Built-in: turtle, math, random Popular: numpy, matplotlib, pandas, folium CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 30 / 48

High-Level vs. Low-Level Languages (codecommit) Can view programming languages on a continuum. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 31 / 48

High-Level vs. Low-Level Languages (codecommit) Can view programming languages on a continuum. Those that directly access machine instructions & memory and have little abstraction are low-level languages CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 31 / 48

High-Level vs. Low-Level Languages (codecommit) Can view programming languages on a continuum. Those that directly access machine instructions & memory and have little abstraction are low-level languages (e.g. machine language, assembly language). CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 31 / 48

High-Level vs. Low-Level Languages (codecommit) Can view programming languages on a continuum. Those that directly access machine instructions & memory and have little abstraction are low-level languages (e.g. machine language, assembly language). Those that have strong abstraction (allow programming paradigms independent of the machine details, such as complex variables, functions and looping that do not translate directly into machine code) are called high-level languages. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 31 / 48

High-Level vs. Low-Level Languages (codecommit) Can view programming languages on a continuum. Those that directly access machine instructions & memory and have little abstraction are low-level languages (e.g. machine language, assembly language). Those that have strong abstraction (allow programming paradigms independent of the machine details, such as complex variables, functions and looping that do not translate directly into machine code) are called high-level languages. Some languages, like C, are in between allowing both low level access and high level data structures. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 31 / 48

Machine Language (Ruth Gordon & Ester Gerston programming the ENIAC, UPenn) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 32 / 48

Machine Language (wiki) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 33 / 48

Machine Language We will be writing programs in a simplified machine language, WeMIPS. (wiki) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 34 / 48

Machine Language We will be writing programs in a simplified machine language, WeMIPS. It is based on a reduced instruction set computer (RISC) design, originally developed by the MIPS Computer Systems. (wiki) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 34 / 48

Machine Language (wiki) We will be writing programs in a simplified machine language, WeMIPS. It is based on a reduced instruction set computer (RISC) design, originally developed by the MIPS Computer Systems. Due to its small set of commands, processors can be designed to run those commands very efficiently. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 34 / 48

Machine Language (wiki) We will be writing programs in a simplified machine language, WeMIPS. It is based on a reduced instruction set computer (RISC) design, originally developed by the MIPS Computer Systems. Due to its small set of commands, processors can be designed to run those commands very efficiently. More in future architecture classes... CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 34 / 48

Hello World! in Simplified Machine Language (WeMIPS) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 35 / 48

WeMIPS (Demo with WeMIPS) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 36 / 48

In Pairs or Triples: Write a program that prints out the alphabet: a b c d... x y z CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 37 / 48

WeMIPS (Demo with WeMIPS) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 38 / 48

Lecture Slip: tinyurl.com/yb8lcvl7 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 39 / 48

Final Overview: Format The exam is 2 hours long. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. The exam format: CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. The exam format: 10 questions, each worth 10 points. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. The exam format: 10 questions, each worth 10 points. Style of questions: what does the code do? short answer, write functions, top down design, & write complete programs. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. The exam format: 10 questions, each worth 10 points. Style of questions: what does the code do? short answer, write functions, top down design, & write complete programs. Sample exam available on-line after Thanksgiving Break. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview: Format The exam is 2 hours long. There are 4 different versions to discourage copying. It is on paper. No use of computers, phones, etc. allowed. You may have 1 piece of 8.5 x 11 piece of paper. With notes, examples, programs: what will help you on the exam. No origami it s distracting to others taking the exam. Best if you design/write yours since excellent way to study. The exam format: 10 questions, each worth 10 points. Style of questions: what does the code do? short answer, write functions, top down design, & write complete programs. Sample exam available on-line after Thanksgiving Break. Mock exam: last day of lecture and discussed in recitation. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 40 / 48

Final Overview For each question below, write only the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that takes a whole number and returns the corresponding binary number as a string. Write a function that takes a weight in kilograms and returns the weight in pounds. Write a function that, given a DataFrame, returns the minimal value in the first column. Write a function that computes the total monthly payment when given the initial loan amount, annual interest rate, number of years of the loan. Write a function that takes a string and returns its length. (Hint: highlight key words, make list of inputs, list of outputs, then put together.) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 41 / 48

Final Overview For each question below, write the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that takes a whole number and returns the corresponding binary number as a string. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 42 / 48

Final Overview For each question below, write the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that takes a weight in kilograms and returns the weight in pounds. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 43 / 48

Final Overview For each question below, write the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that, given a DataFrame, returns the minimal value in the first column. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 44 / 48

Final Overview For each question below, write the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that computes the total monthly payment when given the initial loan amount, annual interest rate, number of years of the loan. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 45 / 48

Final Overview For each question below, write the function header (name & inputs) and return values (often called the Application Programming Interface (API)): Write a function that takes a string and returns its length. CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 46 / 48

Recap: Python, Languages, & Design Python language CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 47 / 48

Recap: Python, Languages, & Design Python language Logical Circuits CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 47 / 48

Recap: Python, Languages, & Design Python language Logical Circuits Simplified Machine Language CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 47 / 48

Recap: Python, Languages, & Design Python language Logical Circuits Simplified Machine Language Design: from written description ( specs ) to function inputs & outputs ( APIs ) CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 47 / 48

Lecture Slip: tinyurl.com/yb8lcvl7 CSci 127 (Hunter) Lecture 11: tinyurl.com/yb8lcvl7 15 November 2017 48 / 48