|
1 | 1 | import turtle
|
| 2 | +import random |
2 | 3 | t = turtle.Turtle()
|
3 |
| -t.left(90) |
4 |
| -t.speed(200) |
| 4 | +num=random.randint(1,1000) |
| 5 | +t.right(num) |
| 6 | +t.speed(num) |
| 7 | +t.left(num) |
5 | 8 |
|
6 | 9 | def tree(i):
|
7 | 10 | if i<10:
|
8 | 11 | return
|
9 | 12 | else:
|
10 |
| - t.forward(i) |
11 |
| - t.left(30) |
| 13 | + t.right(15) |
| 14 | + t.forward(15) |
| 15 | + t.left(20) |
| 16 | + t.backward(20) |
| 17 | + tree(2*i/5) |
| 18 | + t.left(2) |
12 | 19 | tree(3*i/4)
|
13 |
| - t.right(60) |
| 20 | + t.left(2) |
| 21 | + tree(i/2) |
| 22 | + t.backward(num/5) |
| 23 | + tree(random.randint(1,100)) |
| 24 | + tree(random.randint(1,num)) |
| 25 | + tree(random.randint(1,num/2)) |
| 26 | + tree(random.randint(1,num/3)) |
| 27 | + tree(random.randint(1,num/2)) |
| 28 | + tree(random.randint(1,num)) |
| 29 | + tree(random.randint(1,100)) |
| 30 | + t.forward(num/5) |
| 31 | + t.right(2) |
14 | 32 | tree(3*i/4)
|
15 |
| - t.left(30) |
16 |
| - t.backward(i) |
| 33 | + t.right(2) |
| 34 | + tree(2*i/5) |
| 35 | + t.right(2) |
| 36 | + t.left(10) |
| 37 | + t.backward(10) |
| 38 | + t.right(15) |
| 39 | + t.forward(15) |
| 40 | + print('tree execution complete') |
17 | 41 |
|
18 |
| -tree(100) |
| 42 | +def cycle(i): |
| 43 | + if i<10: |
| 44 | + return |
| 45 | + else: |
| 46 | + try: |
| 47 | + tree(random.randint(1,i)) |
| 48 | + tree(random.randint(1,i*2)) |
| 49 | + except: |
| 50 | + print('An exception occured') |
| 51 | + else: |
| 52 | + print('No Exception occured') |
| 53 | + print('cycle loop complete') |
| 54 | + |
| 55 | +def fractal(i): |
| 56 | + if i<10: |
| 57 | + return |
| 58 | + else: |
| 59 | + cycle(random.randint(1,i+1)) |
| 60 | + cycle(random.randint(1,i)) |
| 61 | + cycle(random.randint(1,i-1)) |
| 62 | + cycle(random.randint(1,i-2)) |
| 63 | + print('fractal execution complete') |
| 64 | + |
| 65 | +fractal(random.randint(1,200)) |
| 66 | +print('Execution complete') |
19 | 67 | turtle.done()
|
0 commit comments