34. (8 pts) Write a complete Python program to implement the \"Remove the Wallpa
ID: 3904239 • Letter: 3
Question
34. (8 pts) Write a complete Python program to implement the "Remove the Wallpaper" task. Assume Reeborg starts facing South in the Northwest corner of a completely enclosed rectangular room (with no interior walls). The room is at least. two streets high and two avenues wide. There will be either one or zero beepers on any street corner. Program Reeborg to remove any beepers that may line the perimeter of the room. That is, for each street corner that is adjacent to a wall and has a beper on it, Reeborg should remove the beeper. (Any beepers not on the perimeter are ignored.) This program is short enough to be coded entirely as just a main() routine-do so. Do not define any additional functions. However DO invoke the main() routine at the bottom of your program. Do no use any variables (although it's alright if you use a for statement). To minimize your writing, dou't write comments.Explanation / Answer
#!/usr/bin/python3 # Finds the current hour import datetime time = int(str(datetime.datetime.now().time()).split(":")[0]) # Needed for renaming files import os # List of all files in the folder files = ['05-Evening.png', 'set.py', '07-Night.png', '01-Morning.png', '03-Afternoon.png', '06-Late-Evening.png', '08-Late-Night.png', '04-Late-Afternoon.png', '02-Late-Morning.png', 'now.png'] # Finds which wallpaper is currently set directory = "/home/tessitura/8BitDay/" for filename in os.listdir(directory): files.remove(files[files.index(filename)]) current = ''.join(filename) # Puts back the current wallpaper path = os.path.join(directory, 'now.png') os.rename(path, current) # Gets out the new wallpaper based on time if 0Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.