Write a programBasic10 XPExercise 7/8
Circles by clicking
Task
After every left click draw a circle with radius 25 centred where you clicked. Choose the colour yourself.
The program runs in a tkinter simulation right in your browser - after Run you see the window and can click it. The tests click and check what was drawn on the canvas.
Examples
Call
from tkinter import _mente as okno def sedi(k, x, y): x1, x2 = sorted([k.coords[0], k.coords[2]]) y1, y2 = sorted([k.coords[1], k.coords[3]]) return abs(x1 - (x - 25)) <= 1 and abs(x2 - (x + 25)) <= 1 and abs(y1 - (y - 25)) <= 1 and abs(y2 - (y + 25)) <= 1 okno.click(100, 120) okno.click(300, 200) kruhy = okno.items("oval") okno.check("kazdy klik nakreslil kruh", len(kruhy) == 2, f"kruhov: {len(kruhy)}") okno.check("kruhy maju stred v mieste kliknutia a polomer 25", len(kruhy) == 2 and sedi(kruhy[0], 100, 120) and sedi(kruhy[1], 300, 200))Expected output
kazdy klik nakreslil kruh: OK kruhy maju stred v mieste kliknutia a polomer 25: OK
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.