"* **CS 220 Office Hours** -- As I'm sure you know, you can go to the [course office hours](https://cs220.cs.wisc.edu/s24/schedule.html) to get help with labs and projects.\n",
"* **CS Learning Center** -- Offer free [small group tutoring](https://www.cs.wisc.edu/computer-sciences-learning-center-cslc/), not for debugging your programs, but to talk about course concepts.\n",
"* **Undergraduate Learning Center** -- Provides tutoring and [academic support](https://engineering.wisc.edu/student-services/undergraduate-learning-center/). They have [drop-in tutoring](https://intranet.engineering.wisc.edu/undergraduate-students/ulc/drop-in-tutoring/)."
]
},
{
"cell_type": "markdown",
"metadata": {},
...
...
%% Cell type:markdown id: tags:
# Resources To Improve In The Course
***CS 220 Office Hours** -- As I'm sure you know, you can go to the [course office hours](https://cs220.cs.wisc.edu/s24/schedule.html) to get help with labs and projects.
***CS Learning Center** -- Offer free [small group tutoring](https://www.cs.wisc.edu/computer-sciences-learning-center-cslc/), not for debugging your programs, but to talk about course concepts.
***Undergraduate Learning Center** -- Provides tutoring and [academic support](https://engineering.wisc.edu/student-services/undergraduate-learning-center/). They have [drop-in tutoring](https://intranet.engineering.wisc.edu/undergraduate-students/ulc/drop-in-tutoring/).
%% Cell type:markdown id: tags:
# Lists Practice
%% Cell type:markdown id: tags:
## Warmup
%% Cell type:code id: tags:
``` python
importcsv
# source: Automate the Boring Stuff with Python Ch 12
defprocess_csv(filename):
exampleFile=open(filename,encoding="utf-8")
exampleReader=csv.reader(exampleFile)
exampleData=list(exampleReader)
exampleFile.close()
returnexampleData
cs220_csv=process_csv('cs220_survey_data.csv')
cs220_header=cs220_csv[0]
cs220_data=cs220_csv[1:]
```
%% Cell type:code id: tags:
``` python
# Warmup 0: Hotkeys
# We move quickly, it's good to know some hotkeys!
# All-around good-to-knows...
# Ctrl+A: Select all the text in a cell.
# Ctrl+C: Copy selected text.
# Ctrl+X: Cut selected text.
# Ctrl+V: Paste text from clipboard.
# Ctrl+S: Save.
# Jupyter-specific good-to-knows...
# Ctrl+Enter: Run Cell
# Ctrl+/: Comment/uncomment sections of code.
# Esc->A: Insert cell above
# Esc->B: Insert cell below
# Esc->Shift+L: Toggle line numbers.
```
%% Cell type:code id: tags:
``` python
# Warmup 1: Empty List
weekend_plans=[]# I have no weekend plans :(
print(weekend_plans)
# TODO add three things to your weekend plans using .append
print(weekend_plans)
```
%% Cell type:code id: tags:
``` python
# Warmup 2: Sets
# Like a list, a set is another collection.
# However, it is unordered and unique.
# The function names are also a little different!
my_set_of_weekend_plans=set()
# .add() 4 weekend plans, 1 of which is a duplicate.
print(my_set_of_weekend_plans)
# We can .pop() (note no index as argument) ... but it will remove a random item.
# See https://www.w3schools.com/python/trypython.asp?filename=demo_ref_set_pop2
print(my_set_of_weekend_plans)
# We can .discard() a specific item!
# Unlike a list's remove, this will not throw an error if DNE (does not exist).
print(my_set_of_weekend_plans)
```
%% Cell type:code id: tags:
``` python
# Warmup 3: Improve the cell function...
defcell(row_idx,col_name):
col_idx=cs220_header.index(col_name)
val=cs220_data[row_idx][col_idx]
ifval=="":
returnNone
elifcol_name=="Age":
if"."invalor","inval:
returnNone
returnint(val)
else:
returnval
```
%% Cell type:code id: tags:
``` python
# Warmup 4: Does the oldest basil/spinach-loving Business major prefer cats, dogs, or neither?
```
%% Cell type:code id: tags:
``` python
# Warmup 5: Is their favorite city in the United States?
# The United States has latitudes approximately spanning from 23.101 to 49.632
# and longitudes approximately spanning from -129.306 to -65.017
```
%% Cell type:markdown id: tags:
## Restaurants
%% Cell type:code id: tags:
``` python
restaurant_csv=process_csv('restaurants.csv')
# TODO: Display restaurant_csv. What do we call this data structure?
```
%% Cell type:code id: tags:
``` python
# TODO: Seperate the data into 2 parts...
# a header row, and a list of data rows
```
%% Cell type:code id: tags:
``` python
# TODO: Make a list of just the names from restaurant_data
names=[]# names starts out empty, we will append to it
forrowinrestaurant_data:
pass
names
```
%% Cell type:code id: tags:
``` python
# Convert names to a unique list of names
print(names)
# TODO Convert to a unique list of names
print(names)
```
%% Cell type:code id: tags:
``` python
# Sorting Option 1
print(names)
# TODO: Print the sorted list without changing it.
print(sorted(names))
```
%% Cell type:code id: tags:
``` python
# Sorting Option 2
print(names)
# TODO: Sort the list and print it
names.sort()
print(names)
```
%% Cell type:code id: tags:
``` python
# This is for our debugging sake.
restaurant_header
```
%% Cell type:code id: tags:
``` python
# This is for our debugging sake.
restaurant_data
```
%% Cell type:code id: tags:
``` python
# Define the cell function.
# If there is no data (""), return None
# Return x_coord and y_coord as an int.
# Return all other data as a string.
defcell(row_idx,col_name):
col_idx=restaurant_header.index(col_name)
val=restaurant_data[row_idx][col_idx]
if???:
returnNone
elif???:
returnint(val)
else:
returnval
```
%% Cell type:code id: tags:
``` python
# Write a function that is sent x y coordinates (ints)
# and returns back the restaurant_id of that restaurant.