Deprecated Lab — Trinket is shutting down
This lab was written for Trinket.io, which is shutting down in August 2026. The embedded trinket.io links on this page will stop working after that date.
These pages are kept for reference only. The current version of this course now runs every lab as an inline Skulpt editor right in the page — no account or install needed. Start at Chapter 1: Welcome to Python.
Getting Inputs from the User¶
We can prompt the user to supply a number using the input() function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Example on Trinket¶
Run the Input Example on Trinket
Experiments¶
- Write a program that will prompt the user to enter the number of shapes to draw, the size of the shapes, the color of the shapes and the range of the screen to draw them (50 to 200).
- Add some additional code to check the range of your expected values. If the input is out of range, then continue to prompt the user to enter the correct number until they get a valid number. Use a
whilestatement to continue prompting.