Week 6 of Code in Place

It was the last section!!! Students still have class for week 7, but since they are working on their personal project, there is no section week 7. 

For our last section it was different than weeks prior. We had a game to play called List Index Game – where a list is printed to the terminal and a random element is selected and printed for the user to “guess” the index number of the random element. The second project was about manipulating lists, but not a project like week’s prior.

This week’s key concepts were:

  • List

  • Dictionaries

  • List Index Game


If you want to check it out at: bit.ly/cip-week6. It goes over our check in, a light review of the week’s key concepts and then we jump into coding!

List

We went over that a list is a Collection and that it can contain data structures like strings, integers, floats, etc. We went over how indexes work with List, with a focus on how List’s indexes start at 0. Then we went over common methods like .append() and .pop() and finally how to iterate over a list. 

Dictionaries

We went over how dictionaries are also a Collection, but unlike a list Dictionaries use key:value pairs. We went over how to create a dictionary, how to access its data, adding new key:value and how to delete key:value. At the end we went over how to iterate over a dictionary. Since today’s task in section wasn’t going to deal with dictionaries we didn’t spend as much time with this. 

List Index Game

So Code in Place gave me the code below to “play a game.” I decided to instead of just running the code to play, we spent some time reading the code and “figuring out” what is happening. The group did great with taking a section and explaining what was happening in their two to 4 lines of code. Then we played the game. It was fun because some folks did forget that list indexes start at 0 and I think the learning goal was received.

Coding

The “coding” problem was relatively simple, since we spent time playing the game, the coding project was to practice writing code with lists. Students were to implement the functionality described in the comments, like creating a list, adding a new item, printing the length of the list and printing the list.

import random

def main():
    # Create a list called `fruit_list` that contains the following fruits: 
    # 'apple', 'banana', 'orange', 'grape', 'pineapple'.
    fruit_list = ['apple', 'banana', 'orange', 'grape', 'pineapple']
    
    
    # Print the length of the list.
    print(len(fruit_list))

    
    # Add 'mango' at the end of the list. 
    fruit_list.append("mango")
    


    # Print the updated list.
    # for fruit in fruit_list:
    #     # print("**********************")
    #     # print(fruit_list[i])
    #     print(fruit)
    
    # thing_to_iterate_over = range(len(fruit_list)-1)
    #                         # range(4)
        
    # for i in thing_to_iterate_over:
    #          # range(4)
    #     print(i)
    #     print(fruit_list[i])
    
    print(fruit_list)
    

if __name__ == '__main__':
    main()

Thoughts

We ended the section with a Q&A time. Students asked about different aspects but several asked about what they should do next. I’ve been doing some research on that topic and I actually found a reddit post from the 2020 Code in Place, that was really comprehensive. I also got several students send me private messages thank me for being their section leader, which was very sweet. 

I ended the section with the 16 students that I’ve had for the last few weeks, which is fantastic.

Previous
Previous

Exploring writing in a Memoir Workshop

Next
Next

Week 5 of Code in Place