My Portion of the Group Lesson
Markdown post of my portion of the group lesson.
Managing Complexity with lists - Liav
Long and slow way
- By now, everyone should know the “long and slow way” to print a list of something in python
- It is easy to just assign a value to a single variable
- This method is displayed in this example with test scores:
- As you can see, each score is assigned to its relative variable such as “score1 = 95” and then you just print each variable.
- However you can make the code segment faster, easier to read, and more efficient…
Assinging values to one variable
- Use square brackets “[]” to store the values of a certain variable, then you can simply print the variable to output your desired list:
- Now instead of having a difference variable and new line of code for each value, the list is simply displayed by assigning each value to a single value that you can now print.
How lists manage complexity of a program
- Simplification
- It is much simpler, faster, and easier to code lists this way
- Makes the code segment much easier to read
- Variables
- You do not need as many variables, because you can just assign all corresponding values to a single variable
- To change a value you don’t have to edit/add/remove an entire variable
Python Quiz
- Now everyone should take this short python quiz and screenshot your score.
Simplify Foods List
- Now simplify this foods list using what you have learned
Hacks
- On a single markdown file:
- Insert a screenshot of your score on the python quiz
- Insert a screenshot of your simplifying of the food list
- Why are using lists better for a program, rather than writing out each line of code?
- Make your own list the “long and slow way” then manage the complexity of the list
Rubric
- In ordere to earn a .20/.20 you must
- On a markdown post:
- make an attempt at the python quiz
- Successfully simplify the food list
- Answer the question in detail
- Provide evidence of your own list that you coded