Write a programElementary20 XPExercise 3/8

A text windmill

Task

The program reads a text and a count n and draws a text windmill: n copies of the text that start at one point and are evenly rotated - copy i by i * 360 / n degrees (i = 0, 1, …, n − 1).

Rotate text with the angle parameter of create_text. So that the blades do not all start exactly in the middle, you can put a few spaces before the text or use anchor="w".

You can read the text and the count from the console (input), or from two text fields (Entry) after a button press - then the first field is the text and the second the count.

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
    
    if len(okno.entries()) >= 2 and okno.buttons():
        okno.type("MENTE", entry=0)
        okno.type("8", entry=1)
        okno.press()
    texty = okno.items("text")
    okno.check("pocet textov", len(texty) == 8, f"na platne je {len(texty)} textov")
    okno.check("kazdy text je zadane slovo", texty and all(t.text.strip() == "MENTE" for t in texty))
    uhly = sorted(round(t.angle % 360, 1) for t in texty)
    okno.check("texty su otocene rovnomerne", uhly == [round(i * 360 / 8, 1) for i in range(8)], f"uhly: {uhly}")
    okno.check("vychadzaju z jedneho bodu", len({(round(t.coords[0]), round(t.coords[1])) for t in texty}) == 1)

    Expected output

    pocet textov: OK
    kazdy text je zadane slovo: OK
    texty su otocene rovnomerne: OK
    vychadzaju z jedneho bodu: OK

After you submit, 2 hidden tests will also check your solution: 7 blades, one blade.

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.