What is the os library?
It allows us to "talk" to the console. One of the most powerful things we can do with this library is allow it to clear the console
EXAMPLE:
import os
print("Welcome")
print("to")
print("Replit")
os.system("clear")
username = input("Username: ")
Time Library
We can import a second library by placing a
,
after the name of the first library.EXAMPLE:
import os, time
print("Welcome")
print("to")
print("Replit")
time.sleep(10)
os.system("clear")
username = input("Username: ")
from replit import audio
import os, time
def play():
source = audio.play_file('audio.wav')
source.paused = False # unpause the playback
while True:
stop_playback = int(input("Press 2 anytime to stop playback and go back to the menu : ")) # giving the user the option to stop playback
if stop_playback == 2:
source.paused = True # let's pause the file
return # let's go back from this play() subroutine
else:
continue
while True:
os.system("clear")
print("🎵 MyPOD Music Player ")
time.sleep(1)
print("Press 1 to Play")
time.sleep(1)
print("Press 2 to Exit")
time.sleep(1)
print("Press anything else to see the menu again")
userInput = int(input())
if userInput == 1:
print("Playing some proper tunes!")
play()
elif userInput == 2:
exit()
else :
continue
Comments
Post a Comment