90
CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 10 9 April 2019 1 / 36

CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

  • Upload
    others

  • View
    7

  • Download
    3

Embed Size (px)

Citation preview

Page 1: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CSci 127: Introduction to Computer Science

hunter.cuny.edu/csci

CSci 127 (Hunter) Lecture 10 9 April 2019 1 / 36

Page 2: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Announcements

Postponed until next week:CS Survey: Anna WhitneyGoogle Storage Infrastructure Team

Instead: Final Exam ReviewExtra Handout: fall exam(similar, but due to typos, not identical toexam given)

CSci 127 (Hunter) Lecture 10 9 April 2019 2 / 36

Page 3: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Announcements

Postponed until next week:CS Survey: Anna WhitneyGoogle Storage Infrastructure Team

Instead: Final Exam ReviewExtra Handout: fall exam(similar, but due to typos, not identical toexam given)

CSci 127 (Hunter) Lecture 10 9 April 2019 2 / 36

Page 4: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Today’s Topics

Recap: Folium

Indefinite loops

Design Patterns: Max (Min)

Final Exam Overview

CSci 127 (Hunter) Lecture 10 9 April 2019 3 / 36

Page 5: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Today’s Topics

Recap: Folium

Indefinite loops

Design Patterns: Max (Min)

Final Exam Overview

CSci 127 (Hunter) Lecture 10 9 April 2019 4 / 36

Page 6: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples:What does this code do?

CSci 127 (Hunter) Lecture 10 9 April 2019 5 / 36

Page 7: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium example

What does this code do?

CSci 127 (Hunter) Lecture 10 9 April 2019 6 / 36

Page 8: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium example

What does this code do?

CSci 127 (Hunter) Lecture 10 9 April 2019 6 / 36

Page 9: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium

A module for making HTML maps.

It’s a Python interface to the popularleaflet.js.

Outputs .html files which you can open in abrowser.

An extra step:

Write → Run → Open .htmlcode. program. in browser.

CSci 127 (Hunter) Lecture 10 9 April 2019 7 / 36

Page 10: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium

A module for making HTML maps.

It’s a Python interface to the popularleaflet.js.

Outputs .html files which you can open in abrowser.

An extra step:

Write → Run → Open .htmlcode. program. in browser.

CSci 127 (Hunter) Lecture 10 9 April 2019 7 / 36

Page 11: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium

A module for making HTML maps.

It’s a Python interface to the popularleaflet.js.

Outputs .html files which you can open in abrowser.

An extra step:

Write → Run → Open .htmlcode. program. in browser.

CSci 127 (Hunter) Lecture 10 9 April 2019 7 / 36

Page 12: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium

A module for making HTML maps.

It’s a Python interface to the popularleaflet.js.

Outputs .html files which you can open in abrowser.

An extra step:

Write → Run → Open .htmlcode. program. in browser.

CSci 127 (Hunter) Lecture 10 9 April 2019 7 / 36

Page 13: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Folium

A module for making HTML maps.

It’s a Python interface to the popularleaflet.js.

Outputs .html files which you can open in abrowser.

An extra step:

Write → Run → Open .htmlcode. program. in browser.

CSci 127 (Hunter) Lecture 10 9 April 2019 7 / 36

Page 14: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Today’s Topics

Recap: Folium

Indefinite loops

Design Patterns: Max (Min)

Python Recap

CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36

Page 15: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples:

Write a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

CSci 127 (Hunter) Lecture 10 9 April 2019 9 / 36

Page 16: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number..

CSci 127 (Hunter) Lecture 10 9 April 2019 10 / 36

Page 17: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

def getYear():

CSci 127 (Hunter) Lecture 10 9 April 2019 11 / 36

Page 18: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

def getYear():

return(num)

CSci 127 (Hunter) Lecture 10 9 April 2019 12 / 36

Page 19: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

def getYear():

num = 0

return(num)

CSci 127 (Hunter) Lecture 10 9 April 2019 13 / 36

Page 20: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

def getYear():

num = 0

while num <= 2000 or num >= 2018:

return(num)

CSci 127 (Hunter) Lecture 10 9 April 2019 14 / 36

Page 21: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

CodingWrite a function that asks a user for number after 2000 but before2018. The function should repeatedly ask the user for a number untilthey enter one within the range and return the number.

def getYear():

num = 0

while num <= 2000 or num >= 2018:

num = int(input(’Enter a number > 2000 & < 2018’))

return(num)

CSci 127 (Hunter) Lecture 10 9 April 2019 15 / 36

Page 22: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

Indefinite loops repeat as long asthe condition is true.

Could execute the body of theloop zero times, 10 times, infinitenumber of times.

The condition determines howmany times.

Very useful for checking input,simulations, and games.

CSci 127 (Hunter) Lecture 10 9 April 2019 16 / 36

Page 23: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

Indefinite loops repeat as long asthe condition is true.

Could execute the body of theloop zero times, 10 times, infinitenumber of times.

The condition determines howmany times.

Very useful for checking input,simulations, and games.

CSci 127 (Hunter) Lecture 10 9 April 2019 16 / 36

Page 24: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

Indefinite loops repeat as long asthe condition is true.

Could execute the body of theloop zero times, 10 times, infinitenumber of times.

The condition determines howmany times.

Very useful for checking input,simulations, and games.

CSci 127 (Hunter) Lecture 10 9 April 2019 16 / 36

Page 25: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

Indefinite loops repeat as long asthe condition is true.

Could execute the body of theloop zero times, 10 times, infinitenumber of times.

The condition determines howmany times.

Very useful for checking input,simulations, and games.

CSci 127 (Hunter) Lecture 10 9 April 2019 16 / 36

Page 26: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

Indefinite loops repeat as long asthe condition is true.

Could execute the body of theloop zero times, 10 times, infinitenumber of times.

The condition determines howmany times.

Very useful for checking input,simulations, and games.

CSci 127 (Hunter) Lecture 10 9 April 2019 16 / 36

Page 27: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

CSci 127 (Hunter) Lecture 10 9 April 2019 17 / 36

Page 28: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Indefinite Loops

CSci 127 (Hunter) Lecture 10 9 April 2019 17 / 36

Page 29: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Collect all five stars (locations randomly generated):

CSci 127 (Hunter) Lecture 10 9 April 2019 18 / 36

Page 30: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 31: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, or

I Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 32: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 33: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 34: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 35: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 36: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 37: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.

I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 38: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.

I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 39: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.

I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 40: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

From Last Time: Design Challenge

Possible approaches:

I Randomly wander until all 5 collected, orI Start in one corner, and systematically visit every point.

Input: The map of the ‘world.’

Output: Time taken and/or locations of the 5 stars.

How to store locations? Use numpy array with -1 everywhere.

Possible algorithms: while numStars < 5:

I Move forward.I If wall, mark 0 in map, randomly turn left or right.I If star, mark 1 in map and add 1 to numStars.I Otherwise, mark 2 in map that it’s an empty square.

CSci 127 (Hunter) Lecture 10 9 April 2019 19 / 36

Page 41: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples

Predict what this code does:

CSci 127 (Hunter) Lecture 10 9 April 2019 20 / 36

Page 42: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Trinket Demo

(Demo with trinket)

CSci 127 (Hunter) Lecture 10 9 April 2019 21 / 36

Page 43: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Today’s Topics

Recap: Folium

Indefinite loops

Design Patterns: Max (Min)

Python Recap

CSci 127 (Hunter) Lecture 10 9 April 2019 22 / 36

Page 44: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Patterns

A design pattern is a standard algorithmor approach for solving a commonproblem.

The pattern is independent of theprogramming language.

Can think of as a master recipe, withvariations for different situations.

CSci 127 (Hunter) Lecture 10 9 April 2019 23 / 36

Page 45: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Patterns

A design pattern is a standard algorithmor approach for solving a commonproblem.

The pattern is independent of theprogramming language.

Can think of as a master recipe, withvariations for different situations.

CSci 127 (Hunter) Lecture 10 9 April 2019 23 / 36

Page 46: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Patterns

A design pattern is a standard algorithmor approach for solving a commonproblem.

The pattern is independent of theprogramming language.

Can think of as a master recipe, withvariations for different situations.

CSci 127 (Hunter) Lecture 10 9 April 2019 23 / 36

Page 47: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples:

Predict what the code will do:

CSci 127 (Hunter) Lecture 10 9 April 2019 24 / 36

Page 48: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Python Tutor

(Demo with pythonTutor)

CSci 127 (Hunter) Lecture 10 9 April 2019 25 / 36

Page 49: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Max Design Pattern

Set a variable to the smallest value.

Loop through the list,

If the current number is larger,update your variable.

Print/return the largest number found.

Similar idea works for finding theminimum value.

CSci 127 (Hunter) Lecture 10 9 April 2019 26 / 36

Page 50: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Max Design Pattern

Set a variable to the smallest value.

Loop through the list,

If the current number is larger,update your variable.

Print/return the largest number found.

Similar idea works for finding theminimum value.

CSci 127 (Hunter) Lecture 10 9 April 2019 26 / 36

Page 51: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Max Design Pattern

Set a variable to the smallest value.

Loop through the list,

If the current number is larger,update your variable.

Print/return the largest number found.

Similar idea works for finding theminimum value.

CSci 127 (Hunter) Lecture 10 9 April 2019 26 / 36

Page 52: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Max Design Pattern

Set a variable to the smallest value.

Loop through the list,

If the current number is larger,update your variable.

Print/return the largest number found.

Similar idea works for finding theminimum value.

CSci 127 (Hunter) Lecture 10 9 April 2019 26 / 36

Page 53: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Max Design Pattern

Set a variable to the smallest value.

Loop through the list,

If the current number is larger,update your variable.

Print/return the largest number found.

Similar idea works for finding theminimum value.

CSci 127 (Hunter) Lecture 10 9 April 2019 26 / 36

Page 54: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples:

Answer the following questions on your lecture slip:

Of the students in the room,

Whose name comes first alphabetically?

Whose name comes last alphabetically?

Is there someone in the room with your initials?

CSci 127 (Hunter) Lecture 10 9 April 2019 27 / 36

Page 55: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

In Pairs or Triples:

Design a program that takes a CSV file and a set of initials:

Whose name comes first alphabetically?

Whose name comes last alphabetically?

Is there someone in the room with your initials?

CSci 127 (Hunter) Lecture 10 9 April 2019 28 / 36

Page 56: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

In Pandas, lovely built-in functions:

I df.sort values(’First Name’) andI df[’First Name’].min()

What if you don’t have a CSV and DataFrame, or data not ordered?

CSci 127 (Hunter) Lecture 10 9 April 2019 29 / 36

Page 57: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

In Pandas, lovely built-in functions:I df.sort values(’First Name’) andI df[’First Name’].min()

What if you don’t have a CSV and DataFrame, or data not ordered?

CSci 127 (Hunter) Lecture 10 9 April 2019 29 / 36

Page 58: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

In Pandas, lovely built-in functions:I df.sort values(’First Name’) andI df[’First Name’].min()

What if you don’t have a CSV and DataFrame, or data not ordered?

CSci 127 (Hunter) Lecture 10 9 April 2019 29 / 36

Page 59: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 60: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/max

I Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 61: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").

I For each item, X, in the list:F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 62: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 63: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.

F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 64: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 65: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find first alphabetically

What if you don’t have a CSV and DataFrame, or data not ordered?

Useful Design Pattern: min/maxI Set a variable to worst value (i.e. maxN = 0 or first = "ZZ").I For each item, X, in the list:

F Compare X to your variable.F If better, update your variable to be X.

I Print/return X.

CSci 127 (Hunter) Lecture 10 9 April 2019 30 / 36

Page 66: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find Matching Initials

How do we stop, if we find a match?

Change the loop to be indefinite (i.e. while loop):I Set a variable to found = FalseI while there are items in the list and not found

F If item matches your value, set found = True

I Print/return value.

CSci 127 (Hunter) Lecture 10 9 April 2019 31 / 36

Page 67: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find Matching Initials

How do we stop, if we find a match?

Change the loop to be indefinite (i.e. while loop):I Set a variable to found = False

I while there are items in the list and not foundF If item matches your value, set found = True

I Print/return value.

CSci 127 (Hunter) Lecture 10 9 April 2019 31 / 36

Page 68: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find Matching Initials

How do we stop, if we find a match?

Change the loop to be indefinite (i.e. while loop):I Set a variable to found = FalseI while there are items in the list and not found

F If item matches your value, set found = True

I Print/return value.

CSci 127 (Hunter) Lecture 10 9 April 2019 31 / 36

Page 69: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find Matching Initials

How do we stop, if we find a match?

Change the loop to be indefinite (i.e. while loop):I Set a variable to found = FalseI while there are items in the list and not found

F If item matches your value, set found = True

I Print/return value.

CSci 127 (Hunter) Lecture 10 9 April 2019 31 / 36

Page 70: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Design Question: Find Matching Initials

How do we stop, if we find a match?

Change the loop to be indefinite (i.e. while loop):I Set a variable to found = FalseI while there are items in the list and not found

F If item matches your value, set found = True

I Print/return value.

CSci 127 (Hunter) Lecture 10 9 April 2019 31 / 36

Page 71: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Today’s Topics

Recap: Folium

Indefinite loops

Design Patterns: Max (Min)

Final Exam Overview

CSci 127 (Hunter) Lecture 10 9 April 2019 32 / 36

Page 72: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Recap

On lecture slip, write down a topic you wish wehad spent more time (and why).

Quick recap of a Python library, Folium forcreating interactive HTML maps.

More details on while loops for repeatingcommands for an indefinite number of times.

Introduced the max design pattern.

Pass your lecture slips to the aisles for the UTAsto collect.

CSci 127 (Hunter) Lecture 10 9 April 2019 33 / 36

Page 73: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Recap

On lecture slip, write down a topic you wish wehad spent more time (and why).

Quick recap of a Python library, Folium forcreating interactive HTML maps.

More details on while loops for repeatingcommands for an indefinite number of times.

Introduced the max design pattern.

Pass your lecture slips to the aisles for the UTAsto collect.

CSci 127 (Hunter) Lecture 10 9 April 2019 33 / 36

Page 74: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Recap

On lecture slip, write down a topic you wish wehad spent more time (and why).

Quick recap of a Python library, Folium forcreating interactive HTML maps.

More details on while loops for repeatingcommands for an indefinite number of times.

Introduced the max design pattern.

Pass your lecture slips to the aisles for the UTAsto collect.

CSci 127 (Hunter) Lecture 10 9 April 2019 33 / 36

Page 75: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Recap

On lecture slip, write down a topic you wish wehad spent more time (and why).

Quick recap of a Python library, Folium forcreating interactive HTML maps.

More details on while loops for repeatingcommands for an indefinite number of times.

Introduced the max design pattern.

Pass your lecture slips to the aisles for the UTAsto collect.

CSci 127 (Hunter) Lecture 10 9 April 2019 33 / 36

Page 76: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 77: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 78: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 79: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.

I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 80: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.

I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 81: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.

I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 82: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 83: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:

I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 84: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.

I Questions correspond to the course topics, and are variations on theprogramming assignments, lab exercises, and lecture design challenges.

I Style of questions: what does the code do? short answer, writefunctions, top down design, & write complete programs.

I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 85: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.

I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 86: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 87: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

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.I With notes, examples, programs: what will help you on the exam.I No origami– it’s distracting to others taking the exam.I Best if you design/write yours since excellent way to study.

The exam format:I 10 questions, each worth 10 points.I Questions correspond to the course topics, and are variations on the

programming assignments, lab exercises, and lecture design challenges.I Style of questions: what does the code do? short answer, write

functions, top down design, & write complete programs.I More on logistics after spring break.

Past exams available on webpage (includes answer keys).

CSci 127 (Hunter) Lecture 10 9 April 2019 34 / 36

Page 88: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Exam from Last Semester

Final Exam, Version 3

CSci 127: Introduction to Computer Science

Hunter College, City University of New York

19 December 2018

Exam Rules

• Show all your work. Your grade will be based on the work shown.

• The exam is closed book and closed notes with the exception of an 8 1/2” x 11” piece of paperfilled with notes, programs, etc.

• When taking the exam, you may have with you pens and pencils, and your note sheet.

• You may not use a computer, calculator, tablet, smart watch, or other electronic device.

• Do not open this exam until instructed to do so.

Hunter College regards acts of academic dishonesty (e.g., plagiarism, cheating on examinations,obtaining unfair advantage, and falsification of records and o�cial documents) as serious o↵ensesagainst the values of intellectual honesty. The College is committed to enforcing the CUNY Policyon Academic Integrity and will pursue cases of academic dishonesty according to the Hunter CollegeAcademic Integrity Procedures.

I understand that all cases of academic dishonesty will be reported to the Dean of Students andwill result in sanctions.

Name:

EmpID:

Email:

Signature:

CSci 127 (Hunter) Lecture 10 9 April 2019 35 / 36

Page 89: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

Writing Boards

Return writing boards as you leave...

CSci 127 (Hunter) Lecture 10 9 April 2019 36 / 36

Page 90: CSci 127: Introduction to Computer Science · Python Recap CSci 127 (Hunter) Lecture 10 9 April 2019 8 / 36. In Pairs or Triples: Write a function that asks a user for number after

s

CSci 127 (Hunter) Lecture 10 9 April 2019 36 / 36