Complete the following exercises using the code and concepts from workshop_4. All work should be committed to your GitHub repository.
- Create a Python script that:
- Creates a list of at least 8 integers
- Prints the list and its length
- Calculates and prints the sum of all elements
- Calculates and prints the average of all elements
- Finds and prints the maximum and minimum values
- Reference the approach shown in
list.py
- Write a script that:
- Creates a list of daily temperatures for a 7-day period
- Uses a for loop with enumerate to print each day number and its temperature
- Calculates and prints the average temperature
- Identifies and prints the warmest and coldest days
- Follow the pattern in
list.pybut implement your own solution
- Create a script that implements a number guessing game:
- Generate a random number between 1 and 100 (use
import randomandrandom.randint(1, 100)) - Use a while loop to allow the user to guess the number
- Provide feedback after each guess ("too high" or "too low")
- Count and display the number of guesses when the user guesses correctly
- Generate a random number between 1 and 100 (use
- Reference the approach in
while.py
- Write a script that:
- Uses a loop to iterate through numbers from 1 to 50
- Uses
continueto skip multiples of 3 - Uses
breakto exit the loop when a multiple of 7 that is greater than 30 is found - Prints appropriate messages during the execution
- Follow the pattern shown in
break_continue.py
- Create a calculator program that:
- Uses while loops for input validation
- Asks for two numbers and an operation (+, -, *, /)
- Validates that the inputs for numbers are actually numeric
- Handles division by zero appropriately
- Displays the result and asks if the user wants to perform another calculation
- Reference the validation techniques in
validation.py
- Write a script that:
- Creates a list of strings (e.g., names of friends)
- Allows the user to:
- Add a new name to the list
- Remove a name from the list
- Search for a name in the list
- Display all names in alphabetical order
- Implements proper input validation for all operations
- Continues until the user chooses to exit
- Use concepts from both
list.pyandvalidation.py
- Create a folder named
homework_4in your GitHub repository. - Create separate
.pyfiles for each exercise (6 files total). - Include meaningful comments in your code explaining your logic.
- Make sure to commit and push your changes to GitHub.
- Test all your scripts to ensure they work as expected.
- Proper use of lists and list operations
- Effective implementation of while loops
- Correct use of break and continue statements
- Proper input validation techniques
- Code organization and readability
- Error handling
- Following the submission guidelines