Complete the following exercises using the code and concepts from workshop_5. All work should be committed to your GitHub repository.
- Create a Python script that:
- Creates a list of at least 10 numbers (mixed positive and negative)
- Modifies specific elements by index (change at least 3 elements)
- Prints the list before and after modification
- Adds 5 to every element using a loop
- Prints the final list
- Reference the approach shown in
modify_lists.pyandlists.py
- Write a script that:
- Creates a list of at least 12 integers
- Prints the first half of the list using slicing
- Prints the second half of the list using slicing
- Prints all elements with even indices using slicing
- Prints all elements with odd indices using slicing
- Prints every third element using slicing
- Prints the list in reverse order using slicing
- Follow the pattern in
slices.pybut implement all the required slicing operations
- Create a script that:
- Generates a list of 20 random integers between -100 and 100 (use
import randomandrandom.randint(-100, 100)) - Creates separate lists for:
- Positive numbers
- Negative numbers
- Even numbers
- Odd numbers
- Numbers divisible by 5
- Prints all the separate lists with appropriate labels
- Generates a list of 20 random integers between -100 and 100 (use
- Use techniques from
lists.pyandpop.py
- Write a script that validates a user's password with the following rules:
- Must be at least 8 characters long
- Must contain at least one uppercase letter
- Must contain at least one lowercase letter
- Must contain at least one digit
- Must contain at least one special character (!@#$%^&*)
- Use guard clauses as shown in
guard_clause.pyto provide specific feedback about why the password is invalid - Continue asking for a new password until all criteria are met
- Create an interactive program that:
- Presents a menu of options:
- Add a number to the list
- Remove a number from the list
- Display the current list
- Display the sum and average of the list
- Find the maximum and minimum values
- Clear the list
- Exit the program
- Uses an infinite loop with appropriate break statements
- Implements proper input validation for all operations
- Provides user-friendly feedback for all actions
- Presents a menu of options:
- Implement techniques from
infinite_loop.pyand other workshop files
- Implement the challenge described in
challenge.py:- Create a program that asks the user for numbers indefinitely
- When the user types "done", stop taking new numbers and:
- Save each odd number in a separate list
- Save each number divisible by 7 in a separate list
- Save each number divisible by both 2 and 3 in a separate list
- Print all three list contents with appropriate labels
- Calculate and display the sum and average of each list
- Create a folder named
homework_5in 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 list operations and slicing
- Effective implementation of list filtering and partitioning
- Correct use of guard clauses
- Proper implementation of infinite loops with appropriate exit conditions
- Input validation and user feedback
- Code organization and readability
- Following the submission guidelines