# 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...
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 ...
# Snake Water Gun #Snake,Water and Gun is a variation of the children's game "Rock-Paper-Scissors" # where players use hand gestures to represent a snake, water, or a gun. # The gun beats the snake, the water beats the gun, and the snake beats the water. # Write a python program to create a Snake Water Gun game in Python using if-else statements. # Don't create any fancy GUI. Use proper functions to check for win. # S W G # Computer = 0 1 2 # Player = S 0 D W L # W 1 L D W # G 2 W L D import random def check (comp,user): if comp == user: return 0 if comp == 2 and user == 0 : return - 1 if comp == 1 and user == 2 : return - 1 if comp == 0 and user == 1 : return - 1 else : return 1 comp =random.randint( 0 , 2 ) # print(comp) user = int ( input ( "0 for Snake, 1 for Water, 2 for Gun: \n " )) print ( "You:" ,user) print ( "C...
Comments
Post a Comment