import tkinter as tk from tkinter import messagebox # Initialize current player as "X" and set winner flag to False current_player = "X" winner = False # Function to check for a winner def who_wins (): global winner # List of winning combinations for combo in [[ 0 , 1 , 2 ], [ 3 , 4 , 5 ], [ 6 , 7 , 8 ], [ 0 , 3 , 6 ], [ 1 , 4 , 7 ], [ 2 , 5 , 8 ], [ 0 , 4 , 8 ], [ 2 , 4 , 6 ]]: # Check if the buttons in the current combination have the same text and are not empty if buttons[combo[ 0 ]][ "text" ] == buttons[combo[ 1 ]][ "text" ] == buttons[combo[ 2 ]][ "text" ] != " " : # Highlight the winning combination with a green background buttons[combo[ 0 ]].config( bg = "green" ) buttons[combo[ 1 ]].config( bg = "green" ) buttons[combo[ 2 ]].config( bg = "green" ) # Show a message box declaring the winner ...
# Health Management System # 3 clients - Harry, Merry, Jerry def getdate (): import datetime return datetime.datetime.now() # Total 6 files # write a function that when executed takes as input client name # [Time] chicken,roti # One more function to retrieve exercise or food for any client # ask user to lock or not # then ask for whom to lock: Harry/Merry/Jerry # what to lock Exercise or diet # Write a message that (f"File Written Successfully for {Name}") def take (k): if k == 1 : c = int ( input ( "Enter 1 for Exercise and 2 Diet" )) if c == 1 : value = input ( "Type here \n " ) with open ( "Harry_ex.txt" , "a" ) as op: op.write( str ([ str (getdate())]) + ": " + value + " \n " ) print ( "Successfully Written" ) elif c == 2 : value = input ( "Type here \n " ) with open ( "Harry_di...
# Write a "Library" class with no_of_books(int) and books(list) as two instance variables. # Make a method that checks whether the no_of_books== books(len) # Write a program to create a library from Library class and show how you can print all books, add a book and get the number of books using different methods. # Show that your program dosent persist the books after the program is stopped class Library: def __init__ ( self , no_of_books, books): self .no_of_books = no_of_books self .books = books def check ( self ): # Check whether the number of books matches the length of the books list if self .no_of_books == len ( self .books): print ( "Number of books matches the length of the books list." ) else : print ( "Number of books does not match the length of the books list." ) def print_all_books ( self ): # Print all books in the library print ( "Books in the l...
Comments
Post a Comment