Impress teachers while loop?

We need to draw creative "loops." In the command line, you can see what I can enter. Which values ​​will produce something creative that will impress the teacher and not just be a boring loop? In addition to the formula a=av, we also have a=a*3 (line 18).

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
21 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
JanaL161
4 months ago
Reply to  helenchen947

I am not currently in Python, but have found the following on the Internet; even with turtle: https://github.com/Pirraio/Golden-Spiral/tree/main (golden_spiral.py)

Hope that helps; otherwise I will look again.

SikerimAMK31
4 months ago

Sure. As you design the loop or the loop condition is completely left to you. It is only to be observed that outer syntactic structure:

while [condition]:
    [body]

There are, for example, loops that go backwards, with more complex or non-variable conditions, continuous loops with termination condition etc. The displayed is just a simple example based on the linked code.

SikerimAMK31
4 months ago

Okay, well, let’s start thinking.

for i in range(2):
    doSomethingWith(i)

is nothing but:

for i in [0, 1]:
    doSomethingWith(i)

which in turn is nothing but:

i = 0
while i < 2:
    doSomethingWith(i)
    i = i + 1

By the way, there are also good online dossiers where you can try it directly in the browser, e.g.:

SikerimAMK31
4 months ago

Yeah, so? Each While loop can be easily converted into a For loop and vice versa.

JanaL161
4 months ago

What do you mean no code? The code is in the file I named: https://github.com/Pirraio/Golden-Spiral/blob/main/golden_spiral.py

ajkcdajefiu
4 months ago

try rectangular loops, perhaps crisp loops or wavy loops

you can cut angular loops through straight lines interrupted by 90° turns

wavy loops can make with the sine

ajkcdajefiu~

ajkcdajefiu
4 months ago
Reply to  helenchen947

the other you probably need to tweaked, but an approach would be in line 17 “lt(math.sin(i)), i is a continuously increasing variable (“i += 1” in the loop) to generate the wave effect

Don’t forget to import the math library!

ajkcdajefiu~

ajkcdajefiu
4 months ago

you can stretch the wave or scuba with a prefactor, maybe you can do better?

ajkcdajefiu~

SikerimAMK31
4 months ago

Probably you would impress your teacher the most (and probably take you very positively from the rest of the class) if you actually do your homework yourself.

SikerimAMK31
4 months ago
Reply to  helenchen947

Yeah, you know…

SikerimAMK31
4 months ago

hm, right