First ever lines of code in Py. For testing go to cloud www.codesculptor.org and paste the code in canvas, then press run.Implementation of card game - Memory. Week 5 of 8, assignment #5

# implementation of card game - Memory
 
import simplegui
import random
memory_numbers=[]
 
# helper function to initialize globals
def init():
    global memory_numbers
    numbers = range(8)
    random.shuffle(numbers)
    n1=numbers
 
    random.shuffle(numbers)
    n2=numbers
 
    memory_numbers = n1 + n2
    print memory_numbers
 
 
 
# define event handlers
def mouseclick(pos):
    # add game state logic here
    pass
 
 
# cards are logically 50x100 pixels in size    
def draw(canvas):
    for i in range(50,800,50):
        canvas.draw_line((i , 0), (i , 100), 1, "Blue")
 
 
 
 
# create frame and add a button and labels
frame = simplegui.create_frame("Memory", 800, 100)
frame.add_button("Restart", init)
label = frame.add_label("Moves = 0")
 
# initialize global variables
init()
 
# register event handlers
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)
 
# get things rolling
frame.start()
 
 
# Always remember to review the grading rubric

Leave a Comment

Fields with * are required.

Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.