# MPHY0021 - Day 3 (21st October 2021) :::info ## :tada: Welcome to the third day! First day of :snake: ### Today Today we will - Review the preparation homework reading and quizzes. - Model friendship networks using standard python data structures. - Discuss data structure solutions and review other group's solutions. ::: ### :stopwatch: Time keeper - [name= Gang Lu] :raised_hand: 5' before the end. - 10:00 - 10:50 - 11:05 - 11:55 - 12:05 - 12:55 ### Review from last week - Merging when collaborators both work on the same file (no conflict) - Forking of repositories (working on code that isn't yours) - Branches - Conflicts - :movie_camera: - [Pull requests homework](https://moodle.ucl.ac.uk/mod/lti/view.php?id=3177332), - [Pull requests review](https://moodle.ucl.ac.uk/mod/lti/view.php?id=3177334) and - [Collaborate using VS Code LiveShare](https://moodle.ucl.ac.uk/mod/lti/view.php?id=3177338) - Ongoing git issues? book [office hours slot](https://outlook.office365.com/owa/calendar/MPHY0021@ucl.ac.uk/bookings/) - Fully flipped learning from now on - Pre-lesson work - In class, group work, discussions, screen sharing #### What was discussed during the week :newspaper: - dir function output found methods starting with `_` methods like `__getattribute__` Python has no strict access modifiers like other languages (e.g. `public`, `private`), instead `_` or `__` prefix for method or field is used as a convention - variable unpacking using starred expressions ``` >>> first, *middle, last = list('Unpack me') >>> print(f"{first}\n{middle}\n{last}") U ['n', 'p', 'a', 'c', 'k', ' ', 'm'] e ``` - Notebooks... or not? the notes say we are using notebooks, but that's not true :wink: ### Groups :handshake: We will be using the breaking rooms functionality of Zoom. We have the following groups, and each group have its own document. Once in your breakout-room, find who is chairing that room and open the document linked to that group. :::danger Remember to `rename` yourself by clicking on your zoom name (in the participants list) and change it to: `SGX - Your name` being `X` the number of the group you have been assigned to. If you disconnect and connect again, please rename yourself again. ::: :::warning :question: Name one thing you learned about Python in the class preparation and why do you think it's useful? :snake: ::: - [Group 1: Stef](/1cN9EGzIT42qZK_9Yu74wg) - [Group 2: Alessandro](/9at1wX7nSRSc5k6ij5dbSg) - [Group 3: Anastasis](/GNCHup_GThCA06wYaJn_ww) - [Group 4: Matthew](/06pmGfsLSFW94pLGPvu4vA) - [Group 5: Nisha](/zmfRVpGDQ8qdR6Dypuyv6w) - [Group 6: Nina](/1RFWd_OzT3OgtKv0542DRg) - [Group 7: Ed](/lcHHKImBRL6vfSUn5Z_Okg) ### Preparation check Confidence check: [menti.com](https://www.menti.com/p4tnv584d7) code: 7414 2858 Questions from preparation: - Built in data types, bracket types: - defining: - list `[1, 2, 4]` - dictionaries: `{'car': 'renault', 'colour': 'red'}` - tuple: `(1, 2, 3)` - set: `{1, 2, 3}`. set((1, 2, ,2, 4)) - list[0], dict['car'] - first = 'banana' - favourite_fruit = 'mango' ### Small group work: Mapping friend networks :::info Working in groups of 4 or 5, design a data structure that contains information about a network of friends. Then populate the data structure with the information given. classwork repo: [:hash::seven:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/7) <br> :::spoiler call a helper to your room If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls. If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA). ::: ::: ### Notes on discussion of the excercise [example solution](https://gist.github.com/ageorgou/7cdb4622d8ec53271de2620e936fd692) (this isn't the only solution) In your teaching groups from the introductions, discuss the excercise - what you found tricky or straight forward. Anything you'd do differently? Choose one person from the group to add notes below. **Push any unfinished work and create a PR as the issue asks you to do!** - Group 1: - Complexity of touching the program language at the first time; - How to implement the relationship, cannot add the relationship in the reverse way at one time; - Can do with class for solution; - Creating a new class to hold the things is a tricky way, with such objects could make the code more simple; - Created classes, for group and for people; haven't push the result which would be hard to share; - Could add a relationship function in the person class, which do the job of adding relationships - Group 2: - Class-based solution is different to the sample solution, but has some advantages. - One tricky bit was dealing with uni- and bi-directional relationships (landlord vs friend). - Having several people helped pool knowledge, which was useful - getting everyone to contribute wasn't easy. If the least experienced shares their screen, it prevents more experienced programmers leaving them behind. - hard to wrap mind around `dict` data structure - we wondered about possible approaches to deal with uni- and bi-directional relationships within a class, but then we ran out of time. - [name=Alessandro] there are several possible approaches, but one would maybe be to add two methods (one for uni-, and one for bi-directional relationships) to the class which would allow you to do something like: ```python zalika.add_uni_directional(john, "landlady", "tenant") # makes Zalika John's landlady and John Zalika's tenant zalika.add_bi_directional(jill, "friend") # makes Zalika Jill's friend and vice versa ``` - Group 3: - Initially made a separate dictionary for each person and then put this into another. - Defined multiple classes -- was a new approach - Looked at given examples in the notes - Made lists of every name, every age, etc... which made it complicated to add connections between people - Inconvenient to keep sharing screens, would be good to become efficient at using git (pushing/pulling) - Useful if everyone reads the notes before class, so that everyone is on the same page - Went through iterations of trying to solve the problem, with different solutions - Using lists makes it harder to retrieve information for a specific person. Need to consider how to add information - Getting used to communicating with groups online -- not everyone contributes or it takes time for people to become comfortable - - Group 4: - Tom: Mostly everyone getting involved towards the end. Learnt a lot about dictionary. - Elizabeth: awkwardness in the beginning to get the group going. Take initiative. - Juan: Used indicies and for loop. Similar to the maze problem. Only 2 people talking. - Louise: Used classes. Not sure how to make it work for the rest of the group. - Florin: Just 2 guys contributing. - Shashvat: Choose a design for code that will work for future use cases. Took initiative from the beginning. Managed to finish the Issue 7. Example solution, can easily find who is in the connection. Having a use case for the problem, would help you design the data structure. - Group 5: - Representing the relationships was tricky to figure out. - Working together via zoom was not always easy. - Implementation was straightforward to use dictionaries. - Given more time - would like to have implemented something more sophisticated, not starting with the "perfect"/optimised solution but something that does work - Group 6: - Some groups used classes. Some used dictionaries. - Like the idea of using a fork to edit the code before pushing to the original repo - It was slightly difficult to collaborate with one person sharing screen, some people were not online. - Solution quite similar to the class solution. - What is the advantage/disadvantage of using list versus dictionary? We discussed using keys to access information versus ordered lists. - Group 7: - Some groups tried to use classes and some used dictionaries. - Some groups had some issues with commits. - Some issues with being added to the repository. - Working together over zoom in a group can have its challenges. ### Small group work: review two other group's solutions [An example solution](https://gist.github.com/ageorgou/7cdb4622d8ec53271de2620e936fd692) 1. Push any unfinished work and create a PR as the issue asks you to do! 1. Choose one person to share their screen 1. Pick someone else's PR from the list that appears at the bottom of [the issue](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/7), click on it, and see what they have done (look at the "Files changed" tab on that PR's page to see the actual code changes). 1. Review that PR: leave some comments about things that you find good, or unclear, or any suggestions you have. See [these instructions](https://help.github.com/en/articles/reviewing-proposed-changes-in-a-pull-request) for more details about the interface. :::spoiler problems in breakout room? If you need help, you can ask for us to drop in click "Ask for Help" :grey_question: button in the meeting controls. If you don't find it, [watch this video showing where it is](https://www.youtube.com/watch?v=yIOMPRLQIHA). ::: ### End of class feedback Confidence check: [menti.com](https://www.menti.com/p4tnv584d7) code: 7414 2858 ### Homework - Work complete RSE-Classwork repo issue: [:hash::one::two:](https://github.com/UCL-MPHY0021-21-22/RSE-Classwork/issues/12) - Preparation for week 4 # Questions :::info Feel free to add any question below. Remember the syntax: ``` - Example question - [name=student_a] Example answer - [name=TA_1] Example answer ``` ::: - . Hi David, I am not able to use the UCL SSO system, could you help me get in? by Ziyang (have sent you an email) - [name=...] We have followed up on this by email! - . When and how are the groups for the assignments going to be set? - [name=Anastasis] The first assignment is to be done individually. The groups for the second assignment will be determined in a few weeks, and will be set randomly. From that point on, those will be the groups you will work in during class too. - Thanks! - . - [name=...] ###### tags: `mphy0021` `teaching` `class`