Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
from processing import * global square1, square2, square3, square4, square5, square6, square7, square8, square9, win square1 = " " square2 = " " square3 = " " square4 = " " square5 = " " square6 = " " square7 = " " square8 = " " square9 = " " win = 0 def setup(): size(504, 540) background(169, 169, 169) print "Directions: Make All of the rows and columns add up to 17" print "You must fill out all squares to win" def draw(): global square1, square2, square3, square4, square5, square6, square7, square8, square9 size(300, 350) background(169, 169, 169) drawlines() textSize(20) textAlign(CENTER) text("I'm Done", 150, 325) text(square1, 50, 50) text(square2, 150, 50) text(square3, 250, 50) text(square4, 50, 150) text(square5, 150, 150) text(square6, 250, 150) text(square7, 50, 250) text(square8, 150, 250) text(square9, 250, 250) def drawlines(): stroke(0, 0, 0) for x in range(0, 301, 100): line(x, 0, x, 300) for y in range(0, 306, 100): line(0, y, 300, y) def mouseClicked(): global square1, square2, square3, square4, square5, square6, square7, square8, square9 x = mouse.x y = mouse.y if x > 0 and x < 100 and y > 0 and y < 100: square1 = raw_input("What number goes in this square?") square1 = int(square1) if x > 100 and x < 200 and y > 0 and y < 100: square2 = raw_input("What number goes in this square?") square2 = int(square2) if x > 200 and x < 300 and y > 0 and y < 100: square3 = raw_input("What number goes in this square?") square3 = int(square3) if x > 0 and x < 100 and y > 100 and y < 200: square4 = raw_input("What number goes in this square?") square4 = int(square4) if x > 100 and x < 200 and y > 100 and y < 200: square5 = raw_input("What number goes in this square?") square5 = int(square5) if x > 200 and x < 300 and y > 100 and y < 200: square6 = raw_input("What number goes in this square?") square6 = int(square6) if x > 0 and x < 100 and y > 200 and y < 300: square7 = raw_input("What number goes in this square?") square7 = int(square7) if x > 100 and x < 200 and y > 200 and y < 300: square8 = raw_input("What number goes in this square?") square8 = int(square8) if x > 200 and x < 300 and y > 200 and y < 300: square9 = raw_input("What number goes in this square?") square9 = int(square9) if y > 300: win() def win(): global square1, square2, square3, square4, square5, square6, square7, square8, square9 s1 = square1 s2 = square2 s3 = square3 s4 = square4 s5 = square5 s6 = square6 s7 = square7 s8 = square8 s9 = square9 i = "i" if "i" == i: s1 = int(square1) s2 = int(square2) s3 = int(square3) s4 = int(square4) s5 = int(square5) s6 = int(square6) s7 = int(square7) s8 = int(square8) s9 = int(square9) if (s1 + s2 + s3) == 17: if s4 + s5 + s6 == 17: if s7 + s8 + s9 == 17: if s1 + s4 + s7 == 17: if s2 + s5 + s8 == 17: if s3 + s6 + s9 == 17: print "You Win!!!" else: print "You are incorrect :(" else: print "You are incorrect :(" else: print "You are incorrect :(" else: print "You are incorrect :(" else: print "You are incorrect :(" else: print "You are incorrect :(" run()
Haduku.py
( around 115 lines python code )
Published By:
Mentor Declan
Published on
2017-06-29T13:07:57Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here