Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a Python script file called hw8.py. Add your name at the top as a comment, along with the class name and date. Ex.
Create a Python script file called hw8.py. Add your name at the top as a comment, along with the class name and date. Ex. 1. a. Days of the Week Create a list containing strings for the days of the week, capitalized and in quotes. Store it in a global variable called weekat the top of the program. a. Next Day Write a function called next Day that receives one string representing e of the days and returns the next day. At the top of the function, declare the variable week as global. First, the function should find the index of the day in the list week. If the parameter of the function is called day, the index can be found with the expression week.index (day) Store this value in another variable. After that, use this index to return the next element in the list week: if the index is between 0 and 5, return the element at the position index + 1. Otherwise, if the index is 6, return the first element in the list (at position 0). Note that this function does not require a loop. b. Previous Day Write another function called previous Day that also takes a parameter representing a day as a string, and returns the previous day. Just like in the first one, start by getting the index of the day from the week list. Then return the element of the list at position index-1. Since negative indexes go backward from the end of the list, you don't have to check the value of the index in this one. c. Print Backward Add a function called printBackward that takes one parameter that is a sequence (list, string, or tuple), and prints all the elements from the back to the front. In this function, use a for loop with indexes going from the length of the sequence -1 down to 0, with a step of -1. For each index, print the element of the sequence at that position. c. Test Define a main function where you ask the user to enter a day, store it in a variable, then call the two functions nextDay and previousDay with the variable, and output the results. Then call the function printBackward with the global variable week as a parameter. Add the usual syntax at the end with a call to the function main(): if _main____': main() Test the program a few times to cover all possible cases. name
Step by Step Solution
★★★★★
3.54 Rating (157 Votes )
There are 3 Steps involved in it
Step: 1
Answer Author Your Name Class Your Class Name D...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started