about | help | code help+videos | done | prefs |
cse160-staff@cs.washington.edu cse160_21wi_checkin03
The practice problems for this round are designed to prepare you for Homework 3 which will release on Monday. Homework 3 will involve you manipulating image data.
Image data is often represented as a "grid of pixels". This is the data structure we will use inside of our program to represent an image. We will be using black and white images that can be thought of as a rectangular grid of pixels, where each pixel is represented by an integer between 0 and 255. Inside of our program we will represent this grid as a list of lists of integers. The first (outer) list will be a list of rows of the grid. The length of this list is the "height" of the grid. Each row of the grid will be represented as a list of integers. Each row will be the same length. So the length of any one of these rows is the "width" of the grid. For example, the grid of pixels below would be represented by the list that follows it:
1 5 61 4 3 2 10 11 100[ [1, 5, 61], [4, 3, 2], [10, 11, 100] ]
Here is another example pixel grid and the list that would represent it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15[ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10], [ 11, 12, 13, 14, 15] ]
Assuming this list was assigned to the variable grid, to access the pixel in the top left corner (containing the value 1), you would say:
grid[0][0]To access the value in the bottom right corner (containing the value 15) you would say:
grid[2][4]or you could also say
grid[len(grid)-1][len(grid[0])-1]
If you got credit in canvas for any of the problems from checkin 1 & 2, then you have successfully created an account and shared your answers with us and should just need to be sure you are logged on to the same account for this checkin. Otherwise, please see "To Use CodingBat" below.
Note: Since CodingBat is used for practicing Java as well as Python, there are a few slightly ugly things it does. 1) It uses the term "array" to refer to lists (e.g. [3, 5, 9]). 2) It uses the name "str" to refer to a variable that is a string. This is a bad name to use for a variable since we know we can also use str() to convert things to strings.
Please do these THREE problems by Monday January 25, 2020 11:00pm:
- BE SURE YOU ARE SIGNED IN before you attempt any problems! Otherwise you will have to log in and re-do them in order to get any credit
- You must share your answers with teacher cse160-staff@cs.washington.edu under prefs in order to receive credit
first_last6 H
get_last_pixel H (Hint: READ the explanation above before attempting this!)
sum_grid H (Hint: READ the explanation above before attempting this!)
---------------------------------
To use CodingBat and get credit for the participation assignments we will use it for, you NEED TO CREATE AN ACCOUNT. Do this in the upper right hand corner of this page. In order to receive credit you MUST SIGN UP with your UWnetID email address (e.g. robthomp@uw.edu). After creating your account, in order to get credit for the exercises you do, you should select prefs from the upper right hand corner of this page and then select "Teacher Share" at the bottom of the page and enter this email address, followed by clicking the "Share" button:
cse160-staff@cs.washington.eduYou should also add your name into the memo field as: Last Name, First Name and hit the "Update Memo" button.
---------------------------------
Here are a few suggested practice problems. Do as many of these as you like!
Note: Many of the operations we learned about for lists also apply to strings and vice versa. (e.g. [ ] for indexing and slices, + for concatenating)
Warmups:
missing_char H
front_back H
not_string H
front3 H
front_times H
string_bits H
string_splosion H
last2 H
array_front9 H
array123 H
string_match H
Strings:
make_out_word
extra_end
first_two
first_half
without_end
non_start
left2
count_hi H
Lists:
rotate_left3
reverse3
sum2
middle_way
make_ends
has22
Authoring docs
Copyright Nick Parlante 2017 - privacy