Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from turtle import *
- print('Please enter a number')
- Answer=input('How many figures to draw? ')
- N=int(Answer)
- if Answer.isdigit():
- L=randint(50,100)
- def polygon(L):
- draw(x,y,L,shape)
- def draw(x,y,length,shape):
- up()
- setpos(x,y)
- x=randint(-100,100)
- y=randint(-100,100)
- down()
- for i in range(N):
- for i in range(4):
- while True:
- if f==0:
- if len(circles)>0:
- if len(squares)>0:
- if shape=='circle':
- if shape=='square':
- break
- circle(length/2)
- circles.append(L)
- circles=[]
- else:
- else:
- else:
- else:
- f=randint(0,1)
- forward(L)
- left(90)
- MyFile = open("kt31.txt", "w")
- MyFile.write('The largest circle is '+str(max(circles))+'\n')
- MyFile.write(str(x)+'\t'+str(y)+'\t'+str(L)+'\t'+shape+'\n')
- MyFile.write('The largest square is '+str(max(squares))+'\n')
- MyFile.close()
- polygon(length)
- return False
- return True
- shape='circle'
- shape='square'
- squares.append(L)
- squares=[]
Advertisement
Add Comment
Please, Sign In to add comment