Unit 1, Lesson 4
Materials We Provide
|Lesson||Jupyter Notebook with instructions and empty cells for codealong||Link|
|Solutions||Sample solutions to codealong||Link|
Dataset description: Small, unclean dataset of individuals' numbers of orders from different coffee shops. Used for control flow practice.
Pythoncontrol flow and conditional programming.
Whileloops to iterate through data structures.
if, elseconditional statements.
- Create functions to perform repetitive actions.
- Demonstrate error-handling using
- Combine control flow and conditional statements to solve the classic "FizzBuzz" code challenge.
Pythoncontrol flow and functions to help us parse, clean, edit and analyze the Coffee Preferences dataset.
Before this lesson(s), students should already be able to:
- Know python data types: string, int, float, boolean, tuple, list, dictionary
- If Else Statement
- Write an if-else statement to check whether the suitcase is over 50lb.
- Write an if-else statement for multiple conditions.
- Iterating With For Loops
- Write a for-loop that iterates from the number 1 to the number 15.
- Iterate from 1 to 15, printing whether the number is odd or even.
- Iterate from 1 to 30 with the various instructions.
- Iterate through a list of animals, and print each one in all caps.
- Iterate through the animals list. Capitalize the first letter and append the modified animals to a new list.
- Iterate through the animals. Print out the animal name and the number of vowels in the name.
- Write a function that takes word as an argument and returns the number of vowels in the word.
- Write a function to calculate the area of a triangle using its height and width.
- While Loops
- While loops and strings
- Try to convert elements in a list to floats
- Practice control flow on Coffee Preference dataset
- Load coffee preference data from file and print
- Remove the remaining newline
'\n'characters with a for-loop
- Split the lines into "header" and "data" variables.
- Split the header and the data strings on commas.
- Remove the "Timestamp" column.
- Convert numeric columns to floats and empty fields to
- Count the
Nonevalues per person, and put counts in a dictionary.
- Calculate average rating per coffee brand.
- Create a list containing only the people's names.
- Picking a name at random. What are the odds of choosing the same name three times in a row?
- Construct a while loop to run the choosing function until it returns True.
For more information on this topic, check out the following resources: