Transcript
Page 1: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSci 127: Introduction to Computer Science

hunter.cuny.edu/csci

CSci 127 (Hunter) Lecture 6 3 March 2020 1 / 39

Page 2: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Announcements

Each lecture includes a survey of computingresearch and tech in NYC.

Today: Prof. Kelle Cruz (Astrophysics)

CSci 127 (Hunter) Lecture 6 3 March 2020 2 / 39

Page 3: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 4: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?

We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 5: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 6: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?

Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 7: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 8: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?

Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 9: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 10: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?

Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 11: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Frequently Asked Questions

From lecture slips & recitation sections.

Could you spend more time on circuits/logical expressions/truth tables/decisions?We will start with that today, and more in the following weeks.

I still don’t get indices and the brackets. Could you spend more time on that?Yes, we will, since1) it’s fundamental, and2) the same ideas are used for accessing formatted data (today’s topic).

I still don’t get what is meant by input?Input is data provided to a program each time it runs, it may change at each run.In this course we have used the input() function.

Should I have received email for this course?Absolutely!!! We often send important communication by email. If you have notbeen receiving email from us weekly, please check your spam folder.

CSci 127 (Hunter) Lecture 6 3 March 2020 3 / 39

Page 12: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Today’s Topics

Recap: Logical Expressions & Circuits

Design: Cropping Images

Accessing Formatted Data

CS Survey: Astrophysics and astropy

CSci 127 (Hunter) Lecture 6 3 March 2020 4 / 39

Page 13: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Today’s Topics

Recap: Logical Expressions & Circuits

Design: Cropping Images

Accessing Formatted Data

CS Survey: Astrophysics and astropy

CSci 127 (Hunter) Lecture 6 3 March 2020 5 / 39

Page 14: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap: Logical Operators

and

in1 in2 returns:False and False False

False and True False

True and False False

True and True True

or

in1 in2 returns:False or False False

False or True True

True or False True

True or True True

not

in1 returns:not False True

not True False

CSci 127 (Hunter) Lecture 6 3 March 2020 6 / 39

Page 15: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap: Logical Operators

and

in1 in2 returns:False and False False

False and True False

True and False False

True and True True

or

in1 in2 returns:False or False False

False or True True

True or False True

True or True True

not

in1 returns:not False True

not True False

CSci 127 (Hunter) Lecture 6 3 March 2020 6 / 39

Page 16: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap: Logical Operators

and

in1 in2 returns:False and False False

False and True False

True and False False

True and True True

or

in1 in2 returns:False or False False

False or True True

True or False True

True or True True

not

in1 returns:not False True

not True False

CSci 127 (Hunter) Lecture 6 3 March 2020 6 / 39

Page 17: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Logical Operators & Circuits

Each logical operator (and, or, &not) can be used to join togetherexpressions.

Example: in1 and in2

Each logical operator (and, or, &not) has a corresponding logicalcircuit that can be used to jointogether inputs.

CSci 127 (Hunter) Lecture 6 3 March 2020 7 / 39

Page 18: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Logical Operators & Circuits

Each logical operator (and, or, &not) can be used to join togetherexpressions.

Example: in1 and in2

Each logical operator (and, or, &not) has a corresponding logicalcircuit that can be used to jointogether inputs.

CSci 127 (Hunter) Lecture 6 3 March 2020 7 / 39

Page 19: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Logical Operators & Circuits

Each logical operator (and, or, &not) can be used to join togetherexpressions.

Example: in1 and in2

Each logical operator (and, or, &not) has a corresponding logicalcircuit that can be used to jointogether inputs.

CSci 127 (Hunter) Lecture 6 3 March 2020 7 / 39

Page 20: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Logical Operators & Circuits

Each logical operator (and, or, &not) can be used to join togetherexpressions.

Example: in1 and in2

Each logical operator (and, or, &not) has a corresponding logicalcircuit that can be used to jointogether inputs.

CSci 127 (Hunter) Lecture 6 3 March 2020 7 / 39

Page 21: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Examples: Logical Circuit

(in1 and in2) and in3

CSci 127 (Hunter) Lecture 6 3 March 2020 8 / 39

Page 22: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Examples: Logical Circuit

(in1 and in2) and in3

CSci 127 (Hunter) Lecture 6 3 March 2020 8 / 39

Page 23: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

More Circuit Examples

Examples from last lecture:

Draw a circuit that corresponds to each logical expression:

not( in1 or in2 )

(in1 or in2) and (in1 or in3)

(not(in1 and not in2)) or (in1 and (in2 and in3))

CSci 127 (Hunter) Lecture 6 3 March 2020 9 / 39

Page 24: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples:

Predict what the code will do:

CSci 127 (Hunter) Lecture 6 3 March 2020 10 / 39

Page 25: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Python Tutor

(Demo with pythonTutor)

CSci 127 (Hunter) Lecture 6 3 March 2020 11 / 39

Page 26: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Today’s Topics

Recap: Logical Expressions & Circuits

Design: Cropping Images

Accessing Formatted Data

CS Survey: Astrophysics and astropy

CSci 127 (Hunter) Lecture 6 3 March 2020 12 / 39

Page 27: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

From Final Exam, Fall 2017, V4, #6.

Design an algorithm that reads in an image and displays the lower leftcorner of the image.

Input:Output:Process: (Brainstorm for a “To Do” list to accomplish this.)

CSci 127 (Hunter) Lecture 6 3 March 2020 13 / 39

Page 28: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

From Final Exam, Fall 2017, V4, #6.

Design an algorithm that reads in an image and displays the lower leftcorner of the image.

Input:Output:Process: (Brainstorm for a “To Do” list to accomplish this.)

CSci 127 (Hunter) Lecture 6 3 March 2020 13 / 39

Page 29: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 30: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 31: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 32: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 33: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:

1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 34: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.

2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 35: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.

3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 36: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.

4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 37: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.

5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 38: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.

6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 39: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Question

Design a program that asks the user for an image and then display theupper left quarter of the image. (First, design the pseudocode, and if time,expand to a Python program.)

How to approach this:

Create a “To Do” list of what your program has to accomplish.

Read through the problem, and break it into “To Do” items.

Don’t worry if you don’t know how to do all the items you write down.

Example:1 Import libraries.2 Ask user for an image name.3 Read in image.4 Figure out size of image.5 Make a new image that’s half the height and half the width.6 Display the new image.

CSci 127 (Hunter) Lecture 6 3 March 2020 14 / 39

Page 40: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 41: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 42: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 43: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 44: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 45: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 46: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 47: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 48: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.

img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 49: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 50: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples: Design Question

1 Import libraries.

import matplotlib.pyplot as plt

import numpy as np

2 Ask user for an image name.

inF = input(’Enter file name: ’)

3 Read in image.

img = plt.imread(inF) #Read in image from inF

4 Figure out size of image.

height = img.shape[0] #Get height

width = img.shape[1] #Get width

5 Make a new image that’s half the height and half the width.img2 = img[height//2:, :width//2] #Crop to lower left corner

6 Display the new image.

plt.imshow(img2) #Load our new image into pyplot

plt.show() #Show the image (waits until closed to continue)

CSci 127 (Hunter) Lecture 6 3 March 2020 15 / 39

Page 51: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Today’s Topics

Recap: Logical Expressions & Circuits

Design: Cropping Images

Accessing Formatted Data

CS Survey: Astrophysics and astropy

CSci 127 (Hunter) Lecture 6 3 March 2020 16 / 39

Page 52: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 53: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 54: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 55: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 56: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 57: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

Common to have data structured in a spread sheet.

In the example above, we have the first line that says“Undergraduate”.

Next line has the titles for the columns.

Subsequent lines have a college and attributes about the college.

Python has several ways to read in such data.

We will use the popular Python Data Analysis Library (Pandas).

CSci 127 (Hunter) Lecture 6 3 March 2020 17 / 39

Page 58: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

We will use the popular Python Data Analysis Library (Pandas).

Open source and freely available (part of anaconda distribution).

Already loaded on the machines in 1001E North.

See end of Lab 6 for directions on downloading it to your homemachine.

To use, add to the top of your file:

import pandas as pd

CSci 127 (Hunter) Lecture 6 3 March 2020 18 / 39

Page 59: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

We will use the popular Python Data Analysis Library (Pandas).

Open source and freely available (part of anaconda distribution).

Already loaded on the machines in 1001E North.

See end of Lab 6 for directions on downloading it to your homemachine.

To use, add to the top of your file:

import pandas as pd

CSci 127 (Hunter) Lecture 6 3 March 2020 18 / 39

Page 60: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

We will use the popular Python Data Analysis Library (Pandas).

Open source and freely available (part of anaconda distribution).

Already loaded on the machines in 1001E North.

See end of Lab 6 for directions on downloading it to your homemachine.

To use, add to the top of your file:

import pandas as pd

CSci 127 (Hunter) Lecture 6 3 March 2020 18 / 39

Page 61: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

We will use the popular Python Data Analysis Library (Pandas).

Open source and freely available (part of anaconda distribution).

Already loaded on the machines in 1001E North.

See end of Lab 6 for directions on downloading it to your homemachine.

To use, add to the top of your file:

import pandas as pd

CSci 127 (Hunter) Lecture 6 3 March 2020 18 / 39

Page 62: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Structured Data

We will use the popular Python Data Analysis Library (Pandas).

Open source and freely available (part of anaconda distribution).

Already loaded on the machines in 1001E North.

See end of Lab 6 for directions on downloading it to your homemachine.

To use, add to the top of your file:

import pandas as pd

CSci 127 (Hunter) Lecture 6 3 March 2020 18 / 39

Page 63: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSV Files

Excel .xls files have much extra formatting.

The text file version is called CSV for comma separated values.

Each row is a line in the file.

Columns are separated by commas on each line.

CSci 127 (Hunter) Lecture 6 3 March 2020 19 / 39

Page 64: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSV Files

Excel .xls files have much extra formatting.

The text file version is called CSV for comma separated values.

Each row is a line in the file.

Columns are separated by commas on each line.

CSci 127 (Hunter) Lecture 6 3 March 2020 19 / 39

Page 65: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSV Files

Excel .xls files have much extra formatting.

The text file version is called CSV for comma separated values.

Each row is a line in the file.

Columns are separated by commas on each line.

CSci 127 (Hunter) Lecture 6 3 March 2020 19 / 39

Page 66: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSV Files

Excel .xls files have much extra formatting.

The text file version is called CSV for comma separated values.

Each row is a line in the file.

Columns are separated by commas on each line.

CSci 127 (Hunter) Lecture 6 3 March 2020 19 / 39

Page 67: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CSV Files

nycHistPop.csv

CSci 127 (Hunter) Lecture 6 3 March 2020 20 / 39

Page 68: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Reading in CSV Files

To read in a CSV file: myVar = pd.read csv("myFile.csv")

Pandas has its own type, DataFrame, that is perfect for holding asheet of data.

Often abbreviated: df.

It also has Series, that is perfect for holding a row or column of data.

CSci 127 (Hunter) Lecture 6 3 March 2020 21 / 39

Page 69: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Reading in CSV Files

To read in a CSV file: myVar = pd.read csv("myFile.csv")

Pandas has its own type, DataFrame, that is perfect for holding asheet of data.

Often abbreviated: df.

It also has Series, that is perfect for holding a row or column of data.

CSci 127 (Hunter) Lecture 6 3 March 2020 21 / 39

Page 70: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Reading in CSV Files

To read in a CSV file: myVar = pd.read csv("myFile.csv")

Pandas has its own type, DataFrame, that is perfect for holding asheet of data.

Often abbreviated: df.

It also has Series, that is perfect for holding a row or column of data.

CSci 127 (Hunter) Lecture 6 3 March 2020 21 / 39

Page 71: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Reading in CSV Files

To read in a CSV file: myVar = pd.read csv("myFile.csv")

Pandas has its own type, DataFrame, that is perfect for holding asheet of data.

Often abbreviated: df.

It also has Series, that is perfect for holding a row or column of data.

CSci 127 (Hunter) Lecture 6 3 March 2020 21 / 39

Page 72: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Example: Reading in CSV Files

nycHistPop.csv

In Lab 6

import matplotlib.pyplot as plt

import pandas as pd

pop = pd.read csv(’nycHistPop.csv’,skiprows=5)

pop.plot(x="Year")

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 22 / 39

Page 73: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Example: Reading in CSV Files

nycHistPop.csv

In Lab 6

import matplotlib.pyplot as plt

import pandas as pd

pop = pd.read csv(’nycHistPop.csv’,skiprows=5)

pop.plot(x="Year")

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 22 / 39

Page 74: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Example: Reading in CSV Files

nycHistPop.csv

In Lab 6

import matplotlib.pyplot as plt

import pandas as pd

pop = pd.read csv(’nycHistPop.csv’,skiprows=5)

pop.plot(x="Year")

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 22 / 39

Page 75: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Example: Reading in CSV Files

nycHistPop.csv

In Lab 6

import matplotlib.pyplot as plt

import pandas as pd

pop = pd.read csv(’nycHistPop.csv’,skiprows=5)

pop.plot(x="Year")

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 22 / 39

Page 76: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Example: Reading in CSV Files

nycHistPop.csv

In Lab 6

import matplotlib.pyplot as plt

import pandas as pd

pop = pd.read csv(’nycHistPop.csv’,skiprows=5)

pop.plot(x="Year")

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 22 / 39

Page 77: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Series in Pandas

Series can store a column or row of a DataFrame.

Example: pop["Manhattan"] is the Series corresponding to the column ofManhattan data.

Example:print("The largest number living in the Bronx is",

pop["Bronx"].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 23 / 39

Page 78: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Series in Pandas

Series can store a column or row of a DataFrame.

Example: pop["Manhattan"] is the Series corresponding to the column ofManhattan data.

Example:print("The largest number living in the Bronx is",

pop["Bronx"].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 23 / 39

Page 79: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Series in Pandas

Series can store a column or row of a DataFrame.

Example: pop["Manhattan"] is the Series corresponding to the column ofManhattan data.

Example:print("The largest number living in the Bronx is",

pop["Bronx"].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 23 / 39

Page 80: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 81: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 82: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 83: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 84: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 85: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

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 6 3 March 2020 24 / 39

Page 86: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 87: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 88: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 89: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 90: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 91: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 92: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 93: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 94: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 95: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 96: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 97: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Solutions

Predict what the following will do:

print("Queens:", pop["Queens"].min())

Minimum value in the column with label “Queens”.

print("S I:", pop["Staten Island"].mean())

Average of values in the column “Staten Island”.

print("S I :", pop["Staten Island"].std())

Standard deviation of values in the column “StatenIsland”.

pop.plot.bar(x="Year")

Bar chart with x-axis ”Year”.

pop.plot.scatter(x="Brooklyn", y= "Total")

Scatter plot of Brooklyn versus Total values.

pop["Fraction"] = pop["Bronx"]/pop["Total"]

New column with the fraction of population thatlives in the Bronx.

CSci 127 (Hunter) Lecture 6 3 March 2020 25 / 39

Page 98: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 99: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 100: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 101: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 102: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 103: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

2 Read in the CSV file.

3 Set up a scatter plot.

4 Display plot.

CSci 127 (Hunter) Lecture 6 3 March 2020 26 / 39

Page 104: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 105: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.

import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 106: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 107: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.

pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 108: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.

pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 109: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.

plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 110: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

In Pairs or Triples

cunyF2016.csv

Write a complete Python program thatreads in the file, cunyF2016.csv, andproduces a scatter plot of full-time ver-sus part-time enrollment.

Solution:

1 Include pandas & pyplot libraries.import matplotlib.pyplot as plt

import pandas as pd

2 Read in the CSV file.pop=pd.read csv(’cunyF2016.csv’,skiprows=1)

3 Set up a scatter plot.pop.plot.scatter(x="Full-time",y="Part-time")

4 Display plot.plt.show()

CSci 127 (Hunter) Lecture 6 3 March 2020 27 / 39

Page 111: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 112: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 113: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 114: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 115: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 116: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 28 / 39

Page 117: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring valuesin a column and you want to examinethe data for a particular value.

For example, to find the average rain-fall at each location:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location averages.groupAvg =

rain.groupby(’Location’).mean()

4 Print the average rainfall at eachlocation.print(groupAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 29 / 39

Page 118: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring values in a col-umn and you want to examine the data for aparticular value.

For example, to find the average rainfall atone location, e.g. Moree:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location get averages forgroup Moree.MoreeAvg =

rain.groupby([’Location’]).get group(’Moree’).mean()

4 Print the average rainfall.print(MoreeAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 30 / 39

Page 119: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring values in a col-umn and you want to examine the data for aparticular value.

For example, to find the average rainfall atone location, e.g. Moree:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location get averages forgroup Moree.MoreeAvg =

rain.groupby([’Location’]).get group(’Moree’).mean()

4 Print the average rainfall.print(MoreeAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 30 / 39

Page 120: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

groupby()

AustraliaRain.csv

Sometimes you have recurring values in a col-umn and you want to examine the data for aparticular value.

For example, to find the average rainfall atone location, e.g. Moree:

1 Import libraries.import pandas as pd

2 Read in the CSV file.rain =

pd.read csv(’AustraliaRain.csv’,skiprows=1)

3 Group the data by location get averages forgroup Moree.MoreeAvg =

rain.groupby([’Location’]).get group(’Moree’).mean()

4 Print the average rainfall.print(MoreeAvg[’Rainfall’])

CSci 127 (Hunter) Lecture 6 3 March 2020 30 / 39

Page 121: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Today’s Topics

Recap: Logical Expressions & Circuits

Design: Cropping Images

Accessing Formatted Data

CS Survey: Astrophysics and astropy

CSci 127 (Hunter) Lecture 6 3 March 2020 31 / 39

Page 122: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

CS Survey: Prof. Cruz, Astrophysics

Hunter College - Department of Physics and AstronomyAmerican History Museum - Department of Astrophysics

http://www.hunter.cuny.edu/physics/faculty/cruz/kelle-cruz

CSci 127 (Hunter) Lecture 6 3 March 2020 32 / 39

Page 123: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge

On your Lecture Slip, design an algorithm that:

Prints the luminosity of the brightest star.

Prints the temperature in Kelvin (K) of the coldest star.

Prints the temperature in Fahrenheit of the coldest star. New:astropy.units will seamlessly convert!!!

Prints the average radius of a Hypergiant

CSci 127 (Hunter) Lecture 6 3 March 2020 33 / 39

Page 124: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ columnI Prints min of ’Temperature’ column and store it in temp variableI Use astropy to convert temp variable to Fahrenheit and printI groupby ’Star Type’ and take averages, then print max of ’Radius’

columnI OR groupby ’Star Type’ and get group ’Hypergiant’ to print

average ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 125: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ column

I Prints min of ’Temperature’ column and store it in temp variableI Use astropy to convert temp variable to Fahrenheit and printI groupby ’Star Type’ and take averages, then print max of ’Radius’

columnI OR groupby ’Star Type’ and get group ’Hypergiant’ to print

average ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 126: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ columnI Prints min of ’Temperature’ column and store it in temp variable

I Use astropy to convert temp variable to Fahrenheit and printI groupby ’Star Type’ and take averages, then print max of ’Radius’

columnI OR groupby ’Star Type’ and get group ’Hypergiant’ to print

average ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 127: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ columnI Prints min of ’Temperature’ column and store it in temp variableI Use astropy to convert temp variable to Fahrenheit and print

I groupby ’Star Type’ and take averages, then print max of ’Radius’column

I OR groupby ’Star Type’ and get group ’Hypergiant’ to printaverage ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 128: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ columnI Prints min of ’Temperature’ column and store it in temp variableI Use astropy to convert temp variable to Fahrenheit and printI groupby ’Star Type’ and take averages, then print max of ’Radius’

column

I OR groupby ’Star Type’ and get group ’Hypergiant’ to printaverage ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 129: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Solution

Libraries: pandas and astropy

Process:I Print max of ’Luminosity’ columnI Prints min of ’Temperature’ column and store it in temp variableI Use astropy to convert temp variable to Fahrenheit and printI groupby ’Star Type’ and take averages, then print max of ’Radius’

columnI OR groupby ’Star Type’ and get group ’Hypergiant’ to print

average ’Radius’

CSci 127 (Hunter) Lecture 6 3 March 2020 34 / 39

Page 130: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’columnprint(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 131: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())

I Prints min of ’Temperature’ column and store it in temp variableminTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’columnprint(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 132: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)

I Use astropy to convert temp variable to Fahrenheit and printKUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’columnprint(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 133: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’columnprint(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 134: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’column

print(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 135: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I groupby ’Star Type’ and take averages, then print max of ’Radius’columnprint(stars.groupby([’Star type’])\.mean()[’Radius(R/Ro)’].max())

CSci 127 (Hunter) Lecture 6 3 March 2020 35 / 39

Page 136: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I OR groupby ’Star Type’ and get group ’Hypergiant’ to printaverage ’Radius’print(stars.groupby([’Star type’])\.get group(’Hypergiant’).mean()[’Radius(R/Ro)’])

CSci 127 (Hunter) Lecture 6 3 March 2020 36 / 39

Page 137: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Design Challenge - Code

Libraries: pandas and astropyimport pandas as pd

import astropy.units as u

stars = pd.read csv(’Stars.csv’)

Process:I Print max of ’Luminosity’ column

print(stars[’Luminosity(L/Lo)’].max())I Prints min of ’Temperature’ column and store it in temp variable

minTempK = stars[’Temperature (K)’].min()

print(minTempK)I Use astropy to convert temp variable to Fahrenheit and print

KUnit = minTempK * u.K

print(KUnit.to(u.imperial.deg F, equivalencies = \u.temperature()))

I OR groupby ’Star Type’ and get group ’Hypergiant’ to printaverage ’Radius’print(stars.groupby([’Star type’])\.get group(’Hypergiant’).mean()[’Radius(R/Ro)’])

CSci 127 (Hunter) Lecture 6 3 March 2020 36 / 39

Page 138: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 139: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 140: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 141: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 142: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 143: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Recap

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

Recap: Logical Expressions & Circuits

Accessing Formatted Data:

I Pandas library has elegant solutions foraccessing & analyzing structured data.

I Can manipulate individual columns orrows (’Series’).

I Has useful functions for the entiresheet (’DataFrame’) such as plotting.

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

CSci 127 (Hunter) Lecture 6 3 March 2020 37 / 39

Page 144: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 145: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 146: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:

I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 147: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;

I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 148: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; and

I repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 149: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 150: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 151: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Practice Quiz & Final Questions

xkcd #1508

Since you must pass the final exam to pass the course, we end everylecture with final exam review.

Pull out something to write on (not to be turned in).

Lightning rounds:I write as much you can for 60 seconds;I followed by answer; andI repeat.

Past exams are on the webpage (under Final Exam Information).

Theme: Unix commands!

CSci 127 (Hunter) Lecture 6 3 March 2020 38 / 39

Page 152: CSci 127: Introduction to Computer Science · CSci 127: Introduction to Computer Science hunter.cuny.edu/csci CSci 127 (Hunter) Lecture 6 3 March 20201/39. Announcements Each lecture

Writing Boards

Return writing boards as you leave...

CSci 127 (Hunter) Lecture 6 3 March 2020 39 / 39


Recommended