Homework: ipywidgets
Objective: Learn how to use ipywidgets to create interactive widgets in Google Colab.
Here is the documentation for ipywidgets for your convenience: ipywidgets Documentation
In this homework assignment, you will practice using random numbers, making GUI’s and being creative.
Instructions
- First make a copy of the starter sheet here:
- Rename it something like “(Your_Name)_HW_ipywidgets.ipynb”
- Chose 2 of the following prompts:
- Rock paper scissors
- Number Guessing game
- Password generator
- Add the following elements to each prompt (include which ones you choose in your code and when you submit it):
- Add markdown/HTML with the instructions.
- Add at least 3 GUIs for user interaction
- Show the results in an HTML GUI
- Check the rubric to make sure you have completed all the requirements.
- Turn sharing, editing on. Then turn in the link to learning suite in the feedback box.
Ideas for GUIs
- Rock Paper Scissors
- Add three buttons for the user choices. When the player chooses one button (the rock, paper, or scissors button), the computer will randomly choose one of the three options.
- Number Guessing Game
- Add a text box for the user to input their guess. When the user clicks the submit button, the computer will randomly choose a number between 1 and 100. The user will be told if their guess is too high, too low, or correct.
- Password Generator
- Add a GUI with an appropriate combination of integer sliders checkboxes and/or drop down lists to allow the user to specify the number or characters, uppercase letters, symbols, and numbers to be included. Add a button to generate the password using the requirements specified. Add an HTML widget to show the resulting password.
Turning In/Rubric
Turn on sharing and editing. Turn in the link to the Learning Suite feedback box. ONLY turn in the workbook. **You don't need to turn in the file you created. **
| Item | Amount |
|---|---|
| 2 markdown/HTML instructions (2 points per game) | 4 |
| 6 GUIs added (3 points per GUI, up to 9 per game) | 18 |
| 2 results shown in an HTML GUI (2 points per game) | 4 |
| Write comments explaining the the give code to the games you modified (2 points per game) | 4 |
Total |
30 |
The following is not a part of the rubric, but specifies how you can lose points. For example: if you do not explain your code when using AI to help you create it or fail to share your link correctly.
| Reasons for Points Lost | Amount |
|---|---|
| Link shared incorrectly | -10% |
| Turned in late (per week) | -10% (up to -50%) |
| No comments explaining where AI is used and what its provided code does | -10% |