fork download
  1.  
  2. import turtle
  3. import time
  4. import math
  5. #------------------------------Do not edit below this line--------------------------------------
  6. def drawCircleTurtle():
  7. alex.home()
  8. alex.left(90)
  9. alex.forward(50)
  10. alex.down()
  11. alex.pencolor("blue")
  12.  
  13. for i in range(30):
  14. alex.forward(70)
  15. alex.left(143)
  16. alex.up()
  17. #-------------------------------Do not edit above this line-------------------------------------
  18.  
  19. #Welcome to Python!
  20. #We are going to use a Python library called Turtle to learn about booleans and
  21. #conditionals :)
  22.  
  23. #Our turtle's name is Alex
  24. #----------------------------------------------
  25. ts = turtle.Screen()
  26. ts.bgcolor("orange")
  27. alex = turtle.Turtle()
  28.  
  29. alex.shape("turtle")
  30. alex.up()
  31. alex.color("green")
  32.  
  33. alex.forward(20)
  34.  
  35. alex.forward(100)
  36. alex.left(90)
  37. alex.forward(100)
  38. alex.down()
  39. alex.circle(10)
  40. alex.position()
  41. alex.up()
  42.  
  43. alex.left(90)
  44. alex.forward(210)
  45. alex.right(90)
  46. alex.down()
  47. alex.circle(10)
  48. alex.up
  49.  
  50. alex.left(180)
  51. alex.up()
  52. alex.forward(150)
  53. alex.right(90)
  54. alex.forward(15)
  55. alex.left(90)
  56. alex.down()
  57. alex.circle(120, 180)
  58. alex.up()
  59.  
  60. alex.home()
  61. time.sleep(3)
  62. alex.left(90)
  63.  
  64.  
  65. alex.forward(20)
  66. alex.clear()
  67.  
  68. alex.write("Hello my name is Alex. What is your name?", True, align="center", font=("Ariel",14,"normal"))
  69. alex.left(180)
  70. alex.forward(50)
  71.  
  72. alex.right(90)
  73. alex.forward(170)
  74. ui = input("? ").title()
  75. alex.write("I'm very pleased to meet you {}".format(ui), True, align="center", font=("Ariel",14,"normal"))
  76. alex.home()
  77.  
  78. alex.right(90)
  79. alex.forward(50)
  80. alex.write("Lets play a game!", True, align="center", font=("Ariel",14,"normal"))
  81. alex.home()
  82. time.sleep(2)
  83. alex.clear()
  84.  
  85. #--------------------------Begin Game-------------------------------------------
  86. # alex_talk = "I\'m goint to ask you a True/False question."
  87. # alex.write(alex_talk, True, align="center", font=("Ariel",14,"normal"))
  88. # alex.clear()
  89. alex_talk = "I\'m goint to ask you a True/False question."
  90. alex_talk_1 = "if you give me the right answer..."
  91. alex_talk_2 = "I'll do something cool :)."
  92. alex_talk_3 = "Otherwise..I might get sad and turn blue :)."
  93. alex_talk_4 = "***Ready to play?***"
  94.  
  95. talkinTurtle = (alex_talk,alex_talk_1, alex_talk_2,alex_talk_3,alex_talk_4)
  96.  
  97. for talkin in talkinTurtle:
  98. alex.home()
  99. alex.right(90)
  100. alex.forward(30)
  101. alex_talk_1 = "if you give me the right answer..."
  102. alex.write(talkin, True, align="center", font=("Ariel",14,"normal"))
  103. alex.forward(10)
  104. time.sleep(2)
  105. alex.clear()
  106. #-----------------------Begin Conditionals and Booleans-------------------------
  107. question_1 = "Does 3 * 3 = 9 "
  108. question_2 = "Does Mr Ryan like gummy bears?"
  109. question_3 = "Does 2 + 4 = 6 and does 1 + 1 = 3?"
  110. question_4 = "Does 2 + 4 = 6 or 1 + 1 = 3?"
  111. question_5 = "Does 2 + 4 = 6 but not 1 + 1 = 3?"
  112.  
  113. question_list = [question_1,question_2,question_3,question_4,question_5]
  114.  
  115. for item in question_list:
  116. alex.home()
  117. if item is question_1 or item is question_2 or item is question_4 or item is question_5:
  118. alex.home()
  119. alex.right(90)
  120. alex.forward(30)
  121. alex.write(item, True, align="center", font=("Ariel",14,"normal"))
  122. alex.forward(10)
  123. ui = input("Enter True or False: ").title()
  124. if ui is "True":
  125. alex.clear()
  126. alex.home()
  127. alex.right(90)
  128. alex.forward(30)
  129. alex.write("Nice Job!", True, align="center", font=("Ariel",14,"normal"))
  130. alex.forward(10)
  131. alex.color("purple")
  132. alex.right(720)
  133. time.sleep(2)
  134. alex.clear()
  135. alex.color("green")
  136. elif ui is "False": #means else if
  137. alex.clear()
  138. alex.home()
  139. alex.right(90)
  140. alex.forward(30)
  141. alex.write("Sorry,the answer was True..and now I'm blue", True, align="center", font=("Ariel",14,"normal"))
  142. alex.forward(10)
  143. alex.color("blue")
  144. alex.left(720)
  145. time.sleep(2)
  146. alex.clear()
  147. alex.color("green")
  148. else:
  149. alex.clear()
  150. alex.home()
  151. alex.right(90)
  152. alex.forward(30)
  153. alex.write("You entered" +ui+" Please enter True or False", True, align="center", font=("Ariel",14,"normal"))
  154. time.sleep(2)
  155. alex.clear()
  156. continue
  157. elif item is question_3:
  158. alex.home()
  159. alex.right(90)
  160. alex.forward(30)
  161. alex.write(item, True, align="center", font=("Ariel",14,"normal"))
  162. alex.forward(10)
  163. ui = input("Enter True or False: ").title()
  164. if ui is "False":
  165. alex.clear()
  166. alex.home()
  167. alex.right(90)
  168. alex.forward(30)
  169. alex.write("Nice Job!", True, align="center", font=("Ariel",14,"normal"))
  170. alex.forward(10)
  171. alex.color('black','yellow')
  172. drawCircleTurtle()
  173. alex.up()
  174. time.sleep(2)
  175. alex.clear()
  176. alex.color("green")
  177. elif ui is "True": #means else if
  178. alex.clear()
  179. alex.home()
  180. alex.right(90)
  181. alex.forward(30)
  182. alex.write("Sorry,the answer was False..and now I'm blue", True, align="center", font=("Ariel",14,"normal"))
  183. alex.forward(10)
  184. alex.color("blue")
  185. alex.left(720)
  186. time.sleep(2)
  187. alex.clear()
  188. alex.color("green")
  189. else:
  190. alex.clear()
  191. alex.home()
  192. alex.right(90)
  193. alex.forward(30)
  194. alex.write("You entered: {} Please enter True or False".format(ui), True, align="center", font=("Ariel",14,"normal"))
  195. time.sleep(2)
  196. alex.clear()
  197. continue
  198. #-------------------------------Do Not Edit Below this line---------------------
  199. alex.clear()
  200. alex.home()
  201. alex.right(90)
  202. alex.forward(30)
  203. alex.write("Great Job! Thanks for playing with me! :)", True, align="center", font=("Ariel",14,"normal"))
  204. alex.clear()
  205. alex.home()
  206.  
  207. alex.speed(10)
  208.  
  209. for i in range(183):
  210. alex.forward(100)
  211. alex.right(30)
  212. alex.forward(20)
  213. alex.left(60)
  214. alex.forward(50)
  215. alex.right(30)
  216.  
  217. alex.penup()
  218. alex.setposition(0, 0)
  219. alex.pendown()
  220.  
  221. alex.right(2)
  222.  
  223. turtle.done()
Runtime error #stdin #stdout #stderr 0.02s 122944KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
    import turtle
  File "/usr/lib/pypy/lib-python/2.7/lib-tk/turtle.py", line 107, in <module>
    import Tkinter as TK
  File "/usr/lib/pypy/lib-python/2.7/lib-tk/Tkinter.py", line 42, in <module>
    raise ImportError, str(msg) + ', please install the pypy-tk package'
ImportError: No module named _tkinter, please install the pypy-tk package