Create a Python script file called hw8.py. Add your name at the top as a comment,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
Explain how buyers and sellers factor into setting the stock price for a company's shares. Explain brielfy with the help of examples.
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Why is it so difficult to assess whether a firm is properly valued?
-
Given the following functions F(s), find f(t). F(s) = s2 + 7s + 12 / (s + 2) (s + 4) (s + 6) F(s) = (s + 3) (s + 6) / s (s2 + 10s + 24)
-
Ms Koko is a bond portfolio manager who supports the pure expectations theory of the term structure of interest rates. Her portfolio includes two bonds issued by the same institution (Bond A and Bond...
-
Let x represent the number of registers in use at a departmental store. Determine whether the random variable x is discrete or continuous. Explain.
-
Leda Inc. is located at 433 Augusta Road, Caribou, Maine, 04736, phone number 207-555-1212. The Federal EIN is 54-3910394, and a Maine Revenue Services number of 3884019. Owner, Amanda Leda has asked...
-
Discuss the principles of fluid instabilities and flow instability mechanisms, including Rayleigh-Taylor instability, Kelvin-Helmholtz instability, and Richtmyer- Meshkov instability, and their role...
-
Use PSpice to find V1, V2, and V3 in the network of Fig. 10.128. 8 V. j1012 V, jlOS2 4/0 A
-
Online analytical processing (OLAP) is an information system that enables the user, while at a PC, to query the system, conduct an analysis, and so on. Based on your expertise, perform the following...
-
What do you find practical or useful in this reading assignment? It might be useful in your daily life now, in your professional life now or in the future, in your academic research as you prepare to...
-
Severo S.A. of Sao Paulo, Brazil, is organized into two divisions. The company's contribution format segmented income statement (in terms of the Brazilian currency, the real, R) for last month is...
-
Two springs are attached to an object of mass, 11 kg on a horizontal frictionless surface. Springs constant of both springs is 650N/m. Object is pulled away from the point A, a distance x=8cm as seen...
-
What do you find stimulating or exciting in this reading assignment? Summarize the section and explain why you find it stimulating.
-
On Tuesday October 30, 20XX, an investor sold the following bond at 99: $250,000 face value, 5% Government of Canada semi-annual pay bond, maturing on December 1, 20XX. Calculate the total proceeds...
-
If latent heat of fusion of ice is 80 cals per g at 0C, calculate molal depression constant for water. (a) 18.63 (b) 186.3 (c) 1.863 (d) 0.1863
-
Controls can be identified based on their function. The functions are preventive, detective, and corrective. A. True B. False
-
Here are captions used for a U.S. state census form: Name _____________________________________ Occupation _____________________________________ Address _____________________________________ Zip code...
-
What is the difference between upper and lower CASE tools?
-
What is one specific way to reduce the redundancy of data being entered?
-
Using the demand and cost curves of an individual firm in oligopoly, demonstrate the effects of each of the following: a. The Clean Air Act b. The Nutrition and Labeling Act c. A ban on smoking...
-
Kodak has developed an important brand name through its advertising, innovation, and product quality and service. Suppose Kodak sets up a network of exclusive dealerships, and one of the dealers...
-
Explain why a market in which broadcast licenses can be purchased might be more efficient than having the FCC assign licenses on some basis designed by the FCC.
Study smarter with the SolutionInn App