Part 8.5 | Python Programming | Playing Sound With a While Loop Guessing Game.

Veröffentlicht am: 04 Januar 2023
auf dem Kanal: oOSylarTechOo
90
1

Part 8.5 | Python Programming | Creating a while loop Game with sound

This is part 8.5 of a series of python coding I am having fun with and want to show others interested or stuck.

Code Example:

#Creating a while loop guessing game with sound
#I will be using code from the part 8 video
#This will loop until a condition has been met and play sound

import winsound

#Declare your starting variables with assigned values
guess = 0
ans = 7

guess = int(input("What is your guess? "))

#Creating the while loop that will continue until the correct
#answer is guessed.
while guess != ans:
winsound.PlaySound("laughing.wav", winsound.SND_FILENAME)
guess = int(input("Guess again! "))
if guess == ans:
break
else:
winsound.PlaySound("laughing.wav", winsound.SND_FILENAME)
guess = int(input("Guess again! "))

#Convert guess into a string
sGuess = str(guess)

#Print the results of the guess
winsound.PlaySound("gotcha.wav", winsound.SND_FILENAME)
print("You got it! The answer is " + sGuess)

#python #pythonprogramming #pythontutorial #pythonforbeginners #shorts

Music: Paid Subscription with Wondershare Filmora


Auf dieser Seite können Sie das Online-Video Part 8.5 | Python Programming | Playing Sound With a While Loop Guessing Game. mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer oOSylarTechOo 04 Januar 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 90 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!