Question

Write a function num_day that takes a number in the range of 1 through 7 as...

Write a function num_day that takes a number in the range of 1 through 7 as a parameter and

returns a string representing the corresponding day of the week, where 1=Monday, 2 =Tuesday,

3= Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday.

The function should return the string "Error" if the parameter is that is outside the range of 1 through 7.

You may assume that the parameter will be only numbers.

Save the function in a PyDev library module named functions.py

A sample run:

Please enter a number between 1 and 7:7

The number 7 corresponds to Sunday

Or

Please enter a number between 1 and 7:9

The number 9 corresponds to Error

.

.

Homework Answers

Answer #1
def num_day(n):
    lst = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
    if(n>=1 and n<=7):
        return lst[n-1]
    else:
        return "Error"


# Testing
n = eval(input("Please enter a number between 1 and 7:"))
print("The number",n,"corresponds to",num_day(n))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
As a small restaurant owner, you are very interested in understanding the demand of your different...
As a small restaurant owner, you are very interested in understanding the demand of your different products. You have been collecting data over the past 11 weeks on the number of fish platter sales that you make each day. You want to run a simulation and you believe that 60% of your fish platter sales for a given week show up on the weekends (evenly split between Friday, Saturday and Sunday) while the remaining 40% are evenly divided across the...
10. (17 pts) A person wants to determine whether the proportion of children born each day...
10. (17 pts) A person wants to determine whether the proportion of children born each day of the week is the same or not in a city; that is, the expected relative frequencies are as follows: Day of Week Relative Frequency Sunday 1/7 Monday 1/7 Tuesday 1/7 Wednesday 1/7 Thursday 1/7 Friday 1/7 Saturday 1/7 The person randomly selected a sample of 500 children and the result is as follows: Day of Week Frequency Sunday 57 Monday 78 Tuesday 74...
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of...
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of the week. Assume that a sample of 420 accidents provided the following data. Sunday Monday Tuesday Wednesday Thursday Friday Saturday 69 47 54 49 58 69 74 a. Conduct a hypothesis test to determine if the proportion of traffic accidents is the same for each day of the week. What is the p-value? Compute the value of the X2 test statistic (to 3 decimals)....
So, the brewery selected it’s place and now needs to hire folks. After some testing, they...
So, the brewery selected it’s place and now needs to hire folks. After some testing, they expect to have approximately 2,000 customers per week. Since they will be open 7 days a week, they need to hire people to help serve their beer. They know that Friday and Saturday will drive sales. Between these 2 days, they will get 50% of their weekly sales. So, Friday has 25% of sales and Saturday has 25% of the sales. As for Sunday...
MW is a large discount store that operates seven days per week. The store needs the...
MW is a large discount store that operates seven days per week. The store needs the following number of full-time employees working each day of the week. Sunday Monday Tuesday Wednesday Thursday Friday Saturday num of employees 188 88 112 140 136 172 212 Each employee must work five consecutive days each week and then have two days off. For example, any employee who works Sunday through Thursday has Friday and Saturday off. The store currently has a total of...
Records of randomly selected births were obtained and categorised based on the day of the week...
Records of randomly selected births were obtained and categorised based on the day of the week the birth occurred, which is provided below. Since babies are unaware of the tradition work week, it would be reasonable to assume the distribution of births would occur equally on each of the days of the week. At 1% level of significance, test the claim. Can you think of an explanation for the result? Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday Number of...
Exercise 7. Machine Errors and Days. A manufacturer wishes to see if there is a difference...
Exercise 7. Machine Errors and Days. A manufacturer wishes to see if there is a difference in the distribution for the number of defective bolts produced by at least one of several machines through the work week on the day shift. Six randomly selected machines are evaluated each day for a week. The findings are listed in the table. Let α = 0.05. Using the Friedman Test, can you support the researcher’s claim? Machine Monday Tuesday Wednesday Thursday Friday A...
Ryan likes to listen to music while studying at home. His brother Isaac, however, needs peace...
Ryan likes to listen to music while studying at home. His brother Isaac, however, needs peace and quiet in which to work. They both get an allowance and so have some money. To deal with arguments over whether music is played or not the parents decide that on Monday, Wednesday, Friday and Sunday peace and quiet must reign, but that on Tuesday, Thursday and Saturday it’s ok to play music. Note that the parents set this rule just to avoid...
Ryan likes to listen to music while studying at home. His brother Isaac, however, needs peace...
Ryan likes to listen to music while studying at home. His brother Isaac, however, needs peace and quiet in which to work. They both get an allowance and so have some money. To deal with arguments over whether music is played or not the parents decide that on Monday, Wednesday, Friday and Sunday peace and quiet must reign, but that on Tuesday, Thursday and Saturday it’s ok to play music. Note that the parents set this rule just to avoid...
A group of researchers want to determine if incidents of drunk driving are equally likely to...
A group of researchers want to determine if incidents of drunk driving are equally likely to occur on different days of the week (fe = 0.143). They collect data on drunk driving arrests and calculate frequencies for each day of the week. They collected data from 406 incidents overall. They observed the following frequencies: Sunday (24), Monday (59), Tuesday (46), Wednesday (37), Thursday (50), Friday (92), Saturday (98). Use a one-variable chi-square analysis (where α = .001) to determine if...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT