import random import time def welcome(): print("Welcome to Dr Hey and Dr Yo!") for i in range(5): print("Hey Yo!!") def pause(t): time.sleep(t) #this function returns either "Hey!" or "Yo!" def getScreamWord(): rand = random.randint(0,10) if rand > 5: return "Hey!" else: return "Yo!" #it figures out whose volume to update if the word is "Yo!" def updateVolume(player, screamWord): global vol1,vol2 print(f"{player} screamed {screamWord}!") if player == "Dr Hey" and screamWord == "Yo!": vol1 = vol1+1 #update Dr Hey's volume if player == "Dr Yo" and screamWord == "Yo!": vol2 = vol2+1 #update Dr Yo's volume pause(1) def determineWinner(): if vol1>vol2: print(f"Dr Hey is the winner. Volume: {vol1}") elif vol2>vol1: print(f"Dr Yo is the winner. Volume: {vol2}") else: print(f"It's a Draw! {vol1}") def game(): global vol1, vol2 vol1 = 0 vol2 = 0 #while neither volume is greater than the target, scream!! while vol1 < 5 and vol2 < 5: #Dr Hey screams a word word = getScreamWord() updateVolume("Dr Hey", word) #Dr Yo screams a word word = getScreamWord() updateVolume("Dr Yo", word) #end of screaming, determine the winner determineWinner() #main program, welcome then start the game! def main(): welcome() pause(3) game() #call main to start the program! main()