In a previous lesson, you learned how to use the input() function to
read text from the keyboard. What about the mouse, which is another extremely important way of
interacting with the computer?
There's another function dedicated to reading the mouse call mouse(). Unlike the input() function
which returns the text typed at the keyboard, the mouse() function returns two
values, the $x$ and $y$ coordinates of where the mouse was clicked. Here's how the function works:
Move the mouse over a dotted box for more information.
Now you try. Run this code several times, clicking on different regions of the output window. Does the mouse()
function seem to be reading your click position?
Type your code here:
See your results here:
Share your code
Show a friend, family member, or teacher what you've done!