1 of 17

Discussion 12:

Data Structures in Python

�Grab a worksheet and log onto iClicker!

Question of the Day:

Ask the person to your right / left how they’re doing! Midterm season can be stressful 🫠

2 of 17

Question of the Day!

3 of 17

Question of the Day

Midterm season can be stressful 🫠

  • We want you to succeed! Let me or any course staff know if you are feeling overwhelmed
  • Don’t forget to also talk to course staff for other classes too!
  • If you feel behind, it’s totally okay to ask for extensions!
  • Don’t be too hard on yourself! We are always learning and growing, and that’s okay

4 of 17

Social Implications

5 of 17

AlphaStar AI in StarCraft - Article

  • Able to beat the in-game computer opponents on their hardest setting 95 percent of the time.
  • AI has over 200 years of gameplay experience
  • Trained on professional players user data and strategies
  • “Gets its information directly from the game engine, rather than having to observe the game screen — so it knows instantly that a unit is down to 20 HP without having to click on it.”
  • Can perform far more “actions per minute” than a human

6 of 17

Critical Thinking Questions:

  • AlphaStar was able to beat pro humans in StarCraft, but it may have had "unfair" advantages as a result of being a computer AI, rather than a human. What is one advantage an AI like AlphaStar has over human players?

7 of 17

Translate from Snap!

to Python

For this discussion, you will be using the starter file: tinyurl.com/sp25-disc12

8 of 17

Translate the Snap! code to its Python equivalent:

9 of 17

Translate the Snap! code to its Python equivalent:

10 of 17

Translate to Python list comprehension equivalent:

11 of 17

Translate to Python list comprehension equivalent:

Hint: Combine using the _ + _ in Snap! can be done using the sum(lst) function in Python

12 of 17

Data Structures

13 of 17

Fill out the table below with the Python syntax:

14 of 17

Function Time!

Write a function called merge_dicts that takes in two dictionaries as inputs and returns a new dictionary as output that contains all entries from both input dictionaries. You can assume that both dictionaries have Strings as keys and Integers as values. For any keys present in both dictionaries, the corresponding value in the output dictionary should be the sum of the values from the inputs. You cannot assume both dictionaries are the same length.

15 of 17

Function Time!

Write a function called remove_vowels that takes in a tuple of strings as an input and returns a new tuple as an output that removes all vowels from each string in the output tuple. Hint: Tuples are immutable, but you can always cast a data type like a list to a tuple.

16 of 17

After executing, what’s the value of names

17 of 17

Q&A + Feedback Form

  • Link: tinyurl.com/sp25-disc-form

See you next week!