CSci 127: Introduction to Computer Science
Transcript of CSci 127: Introduction to Computer Science
![Page 1: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/1.jpg)
CSci 127: Introduction to Computer Science
Finished the lecture preview? hunter.cuny.edu/csci
This lecture will be recorded
CSci 127 (Hunter) Lecture 4 28 September 2021 1 / 50
![Page 2: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/2.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 3: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/3.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 4: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/4.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 5: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/5.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 6: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/6.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 7: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/7.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 8: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/8.jpg)
Reminder
This is a VERY large course 700+ students
There are staffing constraints and covid-mandatedcapacity restrictions in lab 1001E
It is important that you make appointments and stickto appointment time (arrival time and duration)
If you think you need more time, please book 2 or 3consecutive tutoring appointments
If a UTA tells you your appointment time is up, pleaseleave the lab and schedule another appointment
If you don’t read the week’s Online Lab it is difficult tohelp you. You will spend your tutoring time doing that
Come to tutoring prepared, read the lab, try thehomework, then come to lab and we will help
CSci 127 (Hunter) Lecture 4 28 September 2021 2 / 50
![Page 9: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/9.jpg)
Why Code Review?
CSci 127 (Hunter) Lecture 4 28 September 2021 3 / 50
![Page 10: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/10.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 11: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/11.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 12: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/12.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem Solving
I Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 13: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/13.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral Communications
I Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 14: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/14.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/Collaboration
I Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 15: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/15.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 16: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/16.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of time
I Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 17: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/17.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointment
I If you know you can’t make it, cancel soit becomes available for others
I If you are late, we will ask you toreschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 18: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/18.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for others
I If you are late, we will ask you toreschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 19: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/19.jpg)
Career Readiness
National Association of Colleges andEmployers (NACE) on Career Readiness
8 Competencies, here you will start developing4:
I Critical Thinking/Problem SolvingI Oral CommunicationsI Teamwork/CollaborationI Digital Technology
But again, we must process 700+ students:
I Make appointments ahead of timeI Be on time for your appointmentI If you know you can’t make it, cancel so
it becomes available for othersI If you are late, we will ask you to
reschedule (can’t guarantee availability)
CSci 127 (Hunter) Lecture 4 28 September 2021 4 / 50
![Page 20: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/20.jpg)
Today’s Topics
Recap: Colors
2D Arrays & Image Files
Decisions
Design Challenge: Airplanes
CSci 127 (Hunter) Lecture 4 28 September 2021 5 / 50
![Page 21: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/21.jpg)
Today’s Topics
Recap: Colors
2D Arrays & Image Files
Decisions
Design Challenge: Airplanes
CSci 127 (Hunter) Lecture 4 28 September 2021 6 / 50
![Page 22: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/22.jpg)
Challenge
CSci 127 (Hunter) Lecture 4 28 September 2021 7 / 50
![Page 23: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/23.jpg)
Challenge
Need to fill in hexcodes (always start with #):
R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 24: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/24.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 25: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/25.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 26: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/26.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 27: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/27.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 28: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/28.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 29: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/29.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2
(any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 30: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/30.jpg)
Challenge
Need to fill in hexcodes (always start with #): R R G G B B
Black: 0 0 0 0 0 0
White: F F F F F F
Blue: 0 0 0 0 F F
Purple: F F 0 0 F F
Gray: 4 2 4 2 4 2 (any choice where RR = GG = BB).
CSci 127 (Hunter) Lecture 4 28 September 2021 8 / 50
![Page 31: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/31.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:I Amount of Red, Green, and Blue (RGB).I Adding light, not paint:
F Black: 0% red, 0% green, 0% blueF White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 32: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/32.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:
I Amount of Red, Green, and Blue (RGB).I Adding light, not paint:
F Black: 0% red, 0% green, 0% blueF White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 33: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/33.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:I Amount of Red, Green, and Blue (RGB).
I Adding light, not paint:F Black: 0% red, 0% green, 0% blueF White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 34: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/34.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:I Amount of Red, Green, and Blue (RGB).I Adding light, not paint:
F Black: 0% red, 0% green, 0% blueF White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 35: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/35.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:I Amount of Red, Green, and Blue (RGB).I Adding light, not paint:
F Black: 0% red, 0% green, 0% blue
F White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 36: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/36.jpg)
Recap: Colors
Can specify by name.
Can specify by numbers:I Amount of Red, Green, and Blue (RGB).I Adding light, not paint:
F Black: 0% red, 0% green, 0% blueF White: 100% red, 100% green, 100% blue
CSci 127 (Hunter) Lecture 4 28 September 2021 9 / 50
![Page 37: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/37.jpg)
Recap: Colors
Can specify by numbers (RGB):
I Fractions of each:e.g. (1.0, 0, 0) is 100% red, no green, and no blue.
I 8-bit colors: numbers from 0 to 255:e.g. (0, 255, 0) is no red, 100% green, and no blue.
I Hexcodes (base-16 numbers)...
CSci 127 (Hunter) Lecture 4 28 September 2021 10 / 50
![Page 38: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/38.jpg)
Recap: Colors
Can specify by numbers (RGB):I Fractions of each:
e.g. (1.0, 0, 0) is 100% red, no green, and no blue.
I 8-bit colors: numbers from 0 to 255:e.g. (0, 255, 0) is no red, 100% green, and no blue.
I Hexcodes (base-16 numbers)...
CSci 127 (Hunter) Lecture 4 28 September 2021 10 / 50
![Page 39: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/39.jpg)
Recap: Colors
Can specify by numbers (RGB):I Fractions of each:
e.g. (1.0, 0, 0) is 100% red, no green, and no blue.I 8-bit colors: numbers from 0 to 255:
e.g. (0, 255, 0) is no red, 100% green, and no blue.
I Hexcodes (base-16 numbers)...
CSci 127 (Hunter) Lecture 4 28 September 2021 10 / 50
![Page 40: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/40.jpg)
Recap: Colors
Can specify by numbers (RGB):I Fractions of each:
e.g. (1.0, 0, 0) is 100% red, no green, and no blue.I 8-bit colors: numbers from 0 to 255:
e.g. (0, 255, 0) is no red, 100% green, and no blue.I Hexcodes (base-16 numbers)...
CSci 127 (Hunter) Lecture 4 28 September 2021 10 / 50
![Page 41: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/41.jpg)
Recap: Hexadecimal
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
CSci 127 (Hunter) Lecture 4 28 September 2021 11 / 50
![Page 42: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/42.jpg)
Colors
Can specify by numbers (RGB):I Fractions of each:
e.g. (1.0, 0, 0) is 100% red, no green, and no blue.I 8-bit colors: numbers from 0 to 255:
e.g. (0, 255, 0) is no red, 100% green, and no blue.I Hexcodes (base-16 numbers):
e.g. #0000FF is no red, no green, and 100% blue.
CSci 127 (Hunter) Lecture 4 28 September 2021 12 / 50
![Page 43: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/43.jpg)
Colors
Can specify by numbers (RGB):I Fractions of each:
e.g. (1.0, 0, 0) is 100% red, no green, and no blue.I 8-bit colors: numbers from 0 to 255:
e.g. (0, 255, 0) is no red, 100% green, and no blue.I Hexcodes (base-16 numbers):
e.g. #0000FF is no red, no green, and 100% blue.
CSci 127 (Hunter) Lecture 4 28 September 2021 12 / 50
![Page 44: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/44.jpg)
Today’s Topics
Recap: Colors
2D Arrays & Image Files
Decisions
Design Challenge: Airplanes
CSci 127 (Hunter) Lecture 4 28 September 2021 13 / 50
![Page 45: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/45.jpg)
Arrays
An array is a sequence ofelements, much like a list.
A 2D array is like a grid ofelements, think a list of lists.
Can keep on adding dimensions(3D, etc.)
Can access pieces/slices as we dowith strings and lists
CSci 127 (Hunter) Lecture 4 28 September 2021 14 / 50
![Page 46: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/46.jpg)
Arrays
An array is a sequence ofelements, much like a list.
A 2D array is like a grid ofelements, think a list of lists.
Can keep on adding dimensions(3D, etc.)
Can access pieces/slices as we dowith strings and lists
CSci 127 (Hunter) Lecture 4 28 September 2021 14 / 50
![Page 47: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/47.jpg)
Arrays
An array is a sequence ofelements, much like a list.
A 2D array is like a grid ofelements, think a list of lists.
Can keep on adding dimensions(3D, etc.)
Can access pieces/slices as we dowith strings and lists
CSci 127 (Hunter) Lecture 4 28 September 2021 14 / 50
![Page 48: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/48.jpg)
Arrays
An array is a sequence ofelements, much like a list.
A 2D array is like a grid ofelements, think a list of lists.
Can keep on adding dimensions(3D, etc.)
Can access pieces/slices as we dowith strings and lists
CSci 127 (Hunter) Lecture 4 28 September 2021 14 / 50
![Page 49: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/49.jpg)
Images
CSci 127 (Hunter) Lecture 4 28 September 2021 15 / 50
![Page 50: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/50.jpg)
Images
CSci 127 (Hunter) Lecture 4 28 September 2021 15 / 50
![Page 51: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/51.jpg)
Images
CSci 127 (Hunter) Lecture 4 28 September 2021 15 / 50
![Page 52: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/52.jpg)
Images
CSci 127 (Hunter) Lecture 4 28 September 2021 15 / 50
![Page 53: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/53.jpg)
Useful Packages
We will use 2 useful packages forimages:
I numpy: numerical analysis packageI pyplot: part of matplotlib for
making graphs and plots
See lab notes for installing on yourhome machine.
CSci 127 (Hunter) Lecture 4 28 September 2021 16 / 50
![Page 54: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/54.jpg)
Useful Packages
We will use 2 useful packages forimages:
I numpy: numerical analysis package
I pyplot: part of matplotlib formaking graphs and plots
See lab notes for installing on yourhome machine.
CSci 127 (Hunter) Lecture 4 28 September 2021 16 / 50
![Page 55: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/55.jpg)
Useful Packages
We will use 2 useful packages forimages:
I numpy: numerical analysis packageI pyplot: part of matplotlib for
making graphs and plots
See lab notes for installing on yourhome machine.
CSci 127 (Hunter) Lecture 4 28 September 2021 16 / 50
![Page 56: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/56.jpg)
Useful Packages
We will use 2 useful packages forimages:
I numpy: numerical analysis packageI pyplot: part of matplotlib for
making graphs and plots
See lab notes for installing on yourhome machine.
CSci 127 (Hunter) Lecture 4 28 September 2021 16 / 50
![Page 57: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/57.jpg)
Images with pyplot and numpy
CSci 127 (Hunter) Lecture 4 28 September 2021 17 / 50
![Page 58: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/58.jpg)
Images with pyplot and numpy
CSci 127 (Hunter) Lecture 4 28 September 2021 18 / 50
![Page 59: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/59.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 60: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/60.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 61: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/61.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 62: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/62.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color
1 to 0% (black):img = np.zeros( (num,num,3) )
2 to 100% (white):img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 63: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/63.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 64: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/64.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )
2 to 100% (white):img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 65: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/65.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 66: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/66.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 67: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/67.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 68: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/68.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 69: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/69.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 70: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/70.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 71: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/71.jpg)
Creating Images
To create an image from scratch:
1 Import the libraries.
import matplotlib.pyplot as plt
import numpy as np
2 Create the image– easy to set all color1 to 0% (black):
img = np.zeros( (num,num,3) )2 to 100% (white):
img = np.ones( (num,num,3) )
3 Do stuff to the pixels to make your image
4 You can display your image:
plt.imshow(img)
plt.show()
5 And save your image:
plt.imsave(’myImage.png’, img)
CSci 127 (Hunter) Lecture 4 28 September 2021 19 / 50
![Page 72: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/72.jpg)
More on numpy arrays
numpy tutorial
CSci 127 (Hunter) Lecture 4 28 September 2021 20 / 50
![Page 73: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/73.jpg)
Slicing & Image Examples
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.zeros( (10,10,3) )
img[0:10,0:5,0:1] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 21 / 50
![Page 74: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/74.jpg)
Slicing & Image Examples
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.zeros( (10,10,3) )
img[0:10,0:5,0:1] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 21 / 50
![Page 75: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/75.jpg)
Slicing & Image Examples
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.zeros( (10,10,3) )
img[0:10,0:5,0:1] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 21 / 50
![Page 76: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/76.jpg)
Slicing & Image ExamplesBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = 10
img = np.zeros( (num,num,3) )
img[0:2,:,2:3] = 1.0
CSci 127 (Hunter) Lecture 4 28 September 2021 22 / 50
![Page 77: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/77.jpg)
Slicing & Image ExamplesBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = 10
img = np.zeros( (num,num,3) )
img[0:2,:,2:3] = 1.0
CSci 127 (Hunter) Lecture 4 28 September 2021 22 / 50
![Page 78: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/78.jpg)
Slicing & Image ExamplesBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = int(input(’Enter size’))
img = np.zeros( (num,num,3) )
img[:,::2,1] = 1.0
CSci 127 (Hunter) Lecture 4 28 September 2021 23 / 50
![Page 79: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/79.jpg)
Slicing & Image ExamplesBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = int(input(’Enter size’))
img = np.zeros( (num,num,3) )
img[:,::2,1] = 1.0
CSci 127 (Hunter) Lecture 4 28 September 2021 23 / 50
![Page 80: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/80.jpg)
Challenge
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.ones( (10,10,3) )
img[0:10,0:5,0:2] = 0
I num = int(input(’Enter size ’))
img = np.ones( (num,num,3) )
img[::2,:,1:] = 0
I img = np.zeros( (8,8,3) )
img[::2,::2,0] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 24 / 50
![Page 81: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/81.jpg)
Challenge
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.ones( (10,10,3) )
img[0:10,0:5,0:2] = 0
I num = int(input(’Enter size ’))
img = np.ones( (num,num,3) )
img[::2,:,1:] = 0
I img = np.zeros( (8,8,3) )
img[::2,::2,0] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 24 / 50
![Page 82: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/82.jpg)
Challenge
Basic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.ones( (10,10,3) )
img[0:10,0:5,0:2] = 0
I num = int(input(’Enter size ’))
img = np.ones( (num,num,3) )
img[::2,:,1:] = 0
I img = np.zeros( (8,8,3) )
img[::2,::2,0] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 24 / 50
![Page 83: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/83.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I img = np.ones( (10,10,3) )
img[0:10,0:5,0:2] = 0
CSci 127 (Hunter) Lecture 4 28 September 2021 25 / 50
![Page 84: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/84.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I img = np.ones( (10,10,3) )
img[0:10,0:5,0:2] = 0
CSci 127 (Hunter) Lecture 4 28 September 2021 25 / 50
![Page 85: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/85.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = int(input(’Enter size ’))
img = np.ones( (num,num,3) )
img[::2,:,1:] = 0
CSci 127 (Hunter) Lecture 4 28 September 2021 26 / 50
![Page 86: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/86.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.Assuming the libraries are imported, what do the following codefragments produce:
I num = int(input(’Enter size ’))
img = np.ones( (num,num,3) )
img[::2,:,1:] = 0
CSci 127 (Hunter) Lecture 4 28 September 2021 26 / 50
![Page 87: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/87.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.zeros( (8,8,3) )
img[::2,1::2,0] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 27 / 50
![Page 88: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/88.jpg)
ChallengeBasic pattern: img[rows, columns, channels] with: start:stop:step.
Assuming the libraries are imported, what do the following codefragments produce:
I img = np.zeros( (8,8,3) )
img[::2,1::2,0] = 1
CSci 127 (Hunter) Lecture 4 28 September 2021 27 / 50
![Page 89: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/89.jpg)
Challenge
1 Design a 10 by 10 logo for Hunter College that contains a purple ‘H’.
2 Your logo should only contain the colors purple and white.
3 How can you make Python draw the logo?Write down a “To Do” list of things you need to do.
4 If time, refine your steps above into a Python program.
CSci 127 (Hunter) Lecture 4 28 September 2021 28 / 50
![Page 90: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/90.jpg)
Challenge
1 Design a 10 by 10 logo for Hunter College that contains a purple ‘H’.2 Your logo should only contain the colors purple and white.
3 How can you make Python draw the logo?Write down a “To Do” list of things you need to do.
4 If time, refine your steps above into a Python program.
CSci 127 (Hunter) Lecture 4 28 September 2021 28 / 50
![Page 91: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/91.jpg)
Challenge
1 Design a 10 by 10 logo for Hunter College that contains a purple ‘H’.2 Your logo should only contain the colors purple and white.
3 How can you make Python draw the logo?Write down a “To Do” list of things you need to do.
4 If time, refine your steps above into a Python program.
CSci 127 (Hunter) Lecture 4 28 September 2021 28 / 50
![Page 92: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/92.jpg)
Challenge
1 Design a 10 by 10 logo for Hunter College that contains a purple ‘H’.2 Your logo should only contain the colors purple and white.
3 How can you make Python draw the logo?Write down a “To Do” list of things you need to do.
4 If time, refine your steps above into a Python program.
CSci 127 (Hunter) Lecture 4 28 September 2021 28 / 50
![Page 93: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/93.jpg)
Design a Hunter Logo
One possible solution:
CSci 127 (Hunter) Lecture 4 28 September 2021 29 / 50
![Page 94: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/94.jpg)
Design a Hunter Logo
1 Create a 10 by 10 array, logo, thatstarts out as all white pixels.
2 Set the 3 left columns to be purple.
3 Set the 3 right columns to be purple.
4 Set the middle 2 rows to be purple.
5 Save logo array to a file.
CSci 127 (Hunter) Lecture 4 28 September 2021 30 / 50
![Page 95: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/95.jpg)
Design a Hunter Logo
1 Create a 10 by 10 array, logo, thatstarts out as all white pixels.
2 Set the 3 left columns to be purple.
3 Set the 3 right columns to be purple.
4 Set the middle 2 rows to be purple.
5 Save logo array to a file.
CSci 127 (Hunter) Lecture 4 28 September 2021 30 / 50
![Page 96: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/96.jpg)
Design a Hunter Logo
1 Create a 10 by 10 array, logo, thatstarts out as all white pixels.
2 Set the 3 left columns to be purple.
3 Set the 3 right columns to be purple.
4 Set the middle 2 rows to be purple.
5 Save logo array to a file.
CSci 127 (Hunter) Lecture 4 28 September 2021 30 / 50
![Page 97: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/97.jpg)
Design a Hunter Logo
1 Create a 10 by 10 array, logo, thatstarts out as all white pixels.
2 Set the 3 left columns to be purple.
3 Set the 3 right columns to be purple.
4 Set the middle 2 rows to be purple.
5 Save logo array to a file.
CSci 127 (Hunter) Lecture 4 28 September 2021 30 / 50
![Page 98: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/98.jpg)
Design a Hunter Logo
1 Create a 10 by 10 array, logo, thatstarts out as all white pixels.
2 Set the 3 left columns to be purple.
3 Set the 3 right columns to be purple.
4 Set the middle 2 rows to be purple.
5 Save logo array to a file.
CSci 127 (Hunter) Lecture 4 28 September 2021 30 / 50
![Page 99: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/99.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
CSci 127 (Hunter) Lecture 4 28 September 2021 31 / 50
![Page 100: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/100.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
CSci 127 (Hunter) Lecture 4 28 September 2021 31 / 50
![Page 101: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/101.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
CSci 127 (Hunter) Lecture 4 28 September 2021 32 / 50
![Page 102: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/102.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
CSci 127 (Hunter) Lecture 4 28 September 2021 32 / 50
![Page 103: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/103.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
CSci 127 (Hunter) Lecture 4 28 September 2021 32 / 50
![Page 104: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/104.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
CSci 127 (Hunter) Lecture 4 28 September 2021 33 / 50
![Page 105: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/105.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
CSci 127 (Hunter) Lecture 4 28 September 2021 33 / 50
![Page 106: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/106.jpg)
Translating the Design to Code1 Create a 10 by 10 array, logo, that starts out as
all white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
CSci 127 (Hunter) Lecture 4 28 September 2021 34 / 50
![Page 107: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/107.jpg)
Translating the Design to Code1 Create a 10 by 10 array, logo, that starts out as
all white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
CSci 127 (Hunter) Lecture 4 28 September 2021 34 / 50
![Page 108: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/108.jpg)
Translating the Design to Code1 Create a 10 by 10 array, logo, that starts out as
all white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
CSci 127 (Hunter) Lecture 4 28 September 2021 34 / 50
![Page 109: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/109.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
5 Save logo array to file.
plt.imsave("logo.png", logoImg) #Save the image to logo.png
CSci 127 (Hunter) Lecture 4 28 September 2021 35 / 50
![Page 110: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/110.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
5 Save logo array to file.
plt.imsave("logo.png", logoImg) #Save the image to logo.png
CSci 127 (Hunter) Lecture 4 28 September 2021 35 / 50
![Page 111: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/111.jpg)
Translating the Design to Code
1 Create a 10 by 10 array, logo, that starts out asall white pixels.
import matplotlib.pyplot as plt #import libraries for plotting
import numpy as np #and for arrays (to hold images)
logoImg = np.ones((10,10,3)) #10x10 array with 3 sheets of 1’s
2 Set the 3 left columns to be purple.
#To make purple, we’ll keep red and blue at 100% and turn green to 0%
logoImg[:,:3,1] = 0 #Turn the green to 0 for first 3 columns
3 Set the 3 right columns to be purple.
logoImg[:,-3:,1] = 0 #Turn the green to 0 for last 3 columns
4 Set the middle 2 rows to be purple.
logoImg[4:6,:,1] = 0 #Turn the green to 0 for middle rows
5 Save logo array to file.
plt.imsave("logo.png", logoImg) #Save the image to logo.png
CSci 127 (Hunter) Lecture 4 28 September 2021 35 / 50
![Page 112: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/112.jpg)
Today’s Topics
Recap: Colors
2D Arrays & Image Files
Decisions
Design Challenge: Airplanes
CSci 127 (Hunter) Lecture 4 28 September 2021 36 / 50
![Page 113: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/113.jpg)
Challenge
Predict what these will do (novel concepts):
CSci 127 (Hunter) Lecture 4 28 September 2021 37 / 50
![Page 114: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/114.jpg)
Python Tutor
(Demo with pythonTutor)
CSci 127 (Hunter) Lecture 4 28 September 2021 38 / 50
![Page 115: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/115.jpg)
IDLE
(Demo with IDLE)
CSci 127 (Hunter) Lecture 4 28 September 2021 39 / 50
![Page 116: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/116.jpg)
Decisions
(This was just a first glance, will do much more on decisions over the nextseveral weeks.)
CSci 127 (Hunter) Lecture 4 28 September 2021 40 / 50
![Page 117: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/117.jpg)
Decisions
(This was just a first glance, will do much more on decisions over the nextseveral weeks.)
CSci 127 (Hunter) Lecture 4 28 September 2021 40 / 50
![Page 118: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/118.jpg)
Decisions
(This was just a first glance, will do much more on decisions over the nextseveral weeks.)
CSci 127 (Hunter) Lecture 4 28 September 2021 40 / 50
![Page 119: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/119.jpg)
Today’s Topics
Recap: Colors
2D Arrays & Image Files
Decisions
Design Challenge: Airplanes
CSci 127 (Hunter) Lecture 4 28 September 2021 41 / 50
![Page 120: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/120.jpg)
What is an Algorithm?
CSci 127 (Hunter) Lecture 4 28 September 2021 42 / 50
![Page 121: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/121.jpg)
Characteristics of an Algorithm
CSci 127 (Hunter) Lecture 4 28 September 2021 43 / 50
![Page 122: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/122.jpg)
Algorithm Design Cycle
CSci 127 (Hunter) Lecture 4 28 September 2021 44 / 50
![Page 123: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/123.jpg)
Design Challenge: Planes
CSci 127 (Hunter) Lecture 4 28 September 2021 45 / 50
![Page 124: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/124.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 125: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/125.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist:
refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 126: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/126.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 127: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/127.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 128: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/128.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 129: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/129.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 130: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/130.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 131: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/131.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 132: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/132.jpg)
Design Challenge: Planes
A classic write-an-algorithm challenge forintroductory programming.
With a slight twist: refining designs
After class:
I Write down your design (different style fromthe one in Lecture Quiz).
I Exchange your design and a blank sheet ofpaper (Input) with a family member orfriend.
I Ask them to follow your design to build anairplane without consulting you.
I When they are done, observe the foldedairplane (Output) and revise youralgorithm.
I Repeat until you are satisfied with yourairplane.
CSci 127 (Hunter) Lecture 4 28 September 2021 46 / 50
![Page 133: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/133.jpg)
Lecture Quiz
Log-in to Gradescope
Find LECTURE 4 Quiz
Take the quiz
You have 5 minutes
CSci 127 (Hunter) Lecture 4 28 September 2021 47 / 50
![Page 134: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/134.jpg)
Recap
In Python, we introduced:
I Recap: ColorsI 2D Array & Image FilesI Decisions
CSci 127 (Hunter) Lecture 4 28 September 2021 48 / 50
![Page 135: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/135.jpg)
Recap
In Python, we introduced:
I Recap: ColorsI 2D Array & Image FilesI Decisions
CSci 127 (Hunter) Lecture 4 28 September 2021 48 / 50
![Page 136: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/136.jpg)
Practice Quiz & Final Questions
(NYTimes) (Hunter College) (FDR 4 FP)
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).
We are starting with Fall 2019, Version 1.
CSci 127 (Hunter) Lecture 4 28 September 2021 49 / 50
![Page 137: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/137.jpg)
Practice Quiz & Final Questions
(NYTimes) (Hunter College) (FDR 4 FP)
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).
We are starting with Fall 2019, Version 1.
CSci 127 (Hunter) Lecture 4 28 September 2021 49 / 50
![Page 138: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/138.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50
![Page 139: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/139.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50
![Page 140: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/140.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50
![Page 141: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/141.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50
![Page 142: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/142.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50
![Page 143: CSci 127: Introduction to Computer Science](https://reader031.fdocuments.net/reader031/viewer/2022012414/616ea1d2c5c1c87a7158fe6b/html5/thumbnails/143.jpg)
Weekly Reminders!
Before next lecture, don’t forget to:
Work on this week’s Online Lab
Schedule an appointment to take the Quiz in lab 1001E Hunter North
If you haven’t already, schedule an appointment to take the CodeReview (one every two weeks) in lab 1001E Hunter North
Submit this week’s 5 programming assignments (programs 16-20)
If you need help, schedule an appointment for Tutoring in lab 1001E11am-5pm
Take the Lecture Preview on Blackboard on Monday (or no later than10am on Tuesday)
CSci 127 (Hunter) Lecture 4 28 September 2021 50 / 50