Guest User

Untitled

a guest
Nov 19th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. from random import randint
  2. from turtle import *
  3.  
  4. print('Please enter a number')
  5. Answer=input('How many figures to draw? ')
  6. N=int(Answer)
  7. if Answer.isdigit():
  8. L=randint(50,100)
  9.  
  10. def polygon(L):
  11. draw(x,y,L,shape)
  12.  
  13. def draw(x,y,length,shape):
  14. up()
  15. setpos(x,y)
  16. x=randint(-100,100)
  17. y=randint(-100,100)
  18. down()
  19.  
  20. for i in range(N):
  21.  
  22. for i in range(4):
  23.  
  24. while True:
  25.  
  26. if f==0:
  27. if len(circles)>0:
  28.  
  29. if len(squares)>0:
  30.  
  31. if shape=='circle':
  32.  
  33. if shape=='square':
  34.  
  35. break
  36. circle(length/2)
  37. circles.append(L)
  38. circles=[]
  39. else:
  40. else:
  41. else:
  42. else:
  43. f=randint(0,1)
  44. forward(L)
  45. left(90)
  46.  
  47. MyFile = open("kt31.txt", "w")
  48. MyFile.write('The largest circle is '+str(max(circles))+'\n')
  49. MyFile.write(str(x)+'\t'+str(y)+'\t'+str(L)+'\t'+shape+'\n')
  50. MyFile.write('The largest square is '+str(max(squares))+'\n')
  51. MyFile.close()
  52.  
  53. polygon(length)
  54. return False
  55. return True
  56. shape='circle'
  57. shape='square'
  58. squares.append(L)
  59. squares=[]
Advertisement
Add Comment
Please, Sign In to add comment