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
На этой странице сайта вы можете посмотреть видео онлайн Part 8.5 | Python Programming | Playing Sound With a While Loop Guessing Game. длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь oOSylarTechOo 04 Январь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 90 раз и оно понравилось 1 зрителям. Приятного просмотра!