مرضیه عباسی – پایه دهم

طراح : مرضیه عباسی

مدرسه : ستوده

پایه : دهم

                    
from tkinter import*
from random import*

computer = ['rock','paper','scissors']
rand = randint(0,2)
comp_choice = computer[rand]

comp_score = 0
my_score = 0

def rock():
    global comp_score
    global my_score
    
    computer = ['rock','paper','scissors']
    rand = randint(0,2)
    comp_choice = computer[rand]
    
    label_your_choice.configure(text = 'your choice was = '+"rock" )
    
    if  comp_choice == computer[0]:
        comp_score = str(comp_score)
        my_score = str(my_score)
        label_comp.configure(text = 'Computers score = '+ comp_score)
        label_you.configure(text = 'Your score = '+ my_score )
        
        
    elif comp_choice == computer[1]:
        comp_score = int(comp_score)+1
        my_score = my_score
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        

    elif comp_choice == computer[2]:
        comp_score = comp_score
        my_score = int(my_score)+1
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        
    label_comp_choice.configure(text = 'computer choice was = '+comp_choice )


def paper():
    global comp_score
    global my_score
    
    computer = ['rock','paper','scissors']
    rand = randint(0,2)
    comp_choice = computer[rand]
    
    
    label_your_choice.configure(text = 'your choice was = '+"paper" )
    
    if  comp_choice == "paper":
        comp_score = str(comp_score)
        my_score = str(my_score)
        label_comp.configure(text = 'Computers score = '+ comp_score)
        label_you.configure(text = 'Your score = '+ my_score )
        

    elif comp_choice == "rock":
        comp_score = comp_score
        my_score = int(my_score) + 1
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        

    elif comp_choice == "scissors":
        comp_score = int(comp_score) + 1
        my_score = my_score
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        
    label_comp_choice.configure(text = 'computer choice was = '+comp_choice )


def scissors():
    global comp_score
    global my_score
    
    computer = ['rock','paper','scissors']
    rand = randint(0,2)
    comp_choice = computer[rand]
    
    label_your_choice.configure(text = 'your choice was = '+"scissor" )
    
    if  comp_choice == "scissors":
        comp_score = str(comp_score)
        my_score = str(my_score)
        label_comp.configure(text = 'Computers score = '+ comp_score)
        label_you.configure(text = 'Your score = '+ my_score )
        

    elif comp_choice == "paper":
        comp_score = comp_score
        my_score = int(my_score) + 1
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        

    elif comp_choice == "rock":
        comp_score = int(comp_score) + 1
        my_score = my_score
        label_comp.configure(text = 'Computers score = '+ str(comp_score))
        label_you.configure(text = 'Your score = '+ str(my_score) )
        
    label_comp_choice.configure(text = 'computer choice was = '+comp_choice )

#window    
form_choice = Tk()
form_choice.geometry('280x200')
form_choice.title('Rock Paper Scissor')

#choose
button_rock = Button(master = form_choice, text = 'Rock', command = rock)
button_paper = Button(master = form_choice, text = 'Paper', command = paper)
button_scissor = Button(master = form_choice, text = 'Scissors', command = scissors)

#score
label_comp = Label(master = form_choice, text = '')
label_you = Label (master = form_choice, text = '')


#choice
label_comp_choice = Label(master = form_choice, text = '')
label_your_choice = Label (master = form_choice, text = '')



button_rock.pack()
button_paper.pack()
button_scissor.pack()
label_comp.pack()  
label_you.pack()
label_comp_choice.pack()
label_your_choice.pack()

mainloop()

آکادمی یاسان : برنامه نویسی ، خلاقیت ، تعامل

پروژه های خلاقیتی دانش آموزان بعد از تلاش یکساله و کسب مهارت هایی که در ضمن آموزش های بازی محور( game based learnig ) به ثمر نشسته است .

سال تحصیلی ۹۹.۴۰۰

مدارس عضو آکادمی یاسان (یاس کلاس )

دیدگاهها

هیچ دیدگاهی برای این محصول نوشته نشده است.

اولین نفری باشید که دیدگاهی را ارسال می کنید برای “مرضیه عباسی – پایه دهم”

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا