Design a function that takes two parameters

Assignment Help Basic Computer Science
Reference no: EM131102826

Must be written in Python 3.5

Cannot use the canned draw_calender function or will receive a zero

The assignment is to create a nicely formatted calendar for any month of any year. 

  1. Length of a Month Design a function that takes two parameters: year and month, and returns an integer indicating how many days long that month is. January 2009 was 31 days long, February 2009 was 28 days long, February 2008 was 29 days long, and so on. Remember that for February, leap years must be taken into account. For this first part, we are only interested in the 21st century. Between the years 2000 and 2099 the leap year rule is very simple: a year is a leap year if it is divisible by four. Incorporate your function into a simple program that allows you to test it conveniently, and then test it conveniently. Each stage of this lab assignment depends on the previous stage, so you won't do any good by going ahead with an incorrect function. 
  2. Day of the Year. Design a function that takes three parameters: year, month, and day, and returns an integer indicating which day of the year that date is. For example, the 1st of January is day 1 of the year, the 2nd of January is day 2, the 1st of February is day 32, and so on. Incorporate your function into a simple program that allows you to test it conveniently, and then test it thoroughly. 
  3. Day of the Century. Now make a function that tells you what day of the century it is. Forget about foolish arguments about whether the century starts in 2000 or 2001. If you take 1st January 2000 as day 1, everything works out nicely. So 31st December 2000 was day 366, and 1st January 2001 was day 367, and so on. You still only need to be concerned with this century, 2000 to 2099.
  4. Day of Forever. You knew this part was coming. Now we want a function that again takes three parameters, representing year, month, and day, but this time, the year could be any positive number. This raises two issues: where to start counting (i.e. what date shall we choose to be day number 1?), and how to handle leap years. Although pedantic folk will argue that there is no such thing as the year 0, pretending that there was makes for a very simple solution. Day 1 will be 1st January of the year 0 regardless of whether or not that date ever existed. It makes the counting easy. The true rules for leap years are slightly more complex than just divisibility by four. The exact rules are given on the last page if you don't already know them, but in summary: Any year that is divisible by 400 is a leap year, any other year that is divisible by 100 is not a leap year, any other year that is divisible by 4 is a leap year, and any other year is not a leap year. Here are some pre-calculated samples to help with testing: 1st January 2000 was day number 730486 4th July 1776 was day number 648857 2nd, 3rd, and 4th of October 2012 are days 735144, 735145, and 735146 27th November 2737 will be the millionth day 1st January of the year 10 A.D. was day 3654 Give some serious thought to testing. If you are getting the wrong number for a date, try some very close dates, and you are likely to spot a pattern in the error that will give you a big clue about where your program may be wrong. 
  5. Day of the Week. Now make a function that takes year, month, and day as parameters, and tells you what day of the week that date was. In some strange and wild countries, such as Czechoslovakia, the week starts on a Monday. We'll keep them happy. Make your function return the answer as an int, using 0 for Monday, 1 for Tuesday, ..., and 6 for Sunday. This is very easy if you think of the modulo % operator and remember how many days there are in a week. Also, make it flexible so that you could start the calendar on any day and you could then sell it in any strange and wild countries. 
  6. A Calendar for a Month. Use that function in a program that allows the user to enter two integers, representing year and month, and then prints a correctly formatted calendar for that day and month. Like this, which would come from an input of 2014 2: Mo Tu We Th Fr Sa Su 12 3456789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

You certainly know how to print out a list of numbers starting from 1. To make those numbers come out looking like a calendar, you need to work out how many spaces to print before the "1", and how to tell when it is time to start a new line. You also need to take a little care to get the alignment of one and two digit numbers right. 

  1. A solid Product. Make sure that your calendar works for any year, not just in the 21st Century, And enable the user to print a calendar that starts on any day not just Monday. 
  2. Write a function that works out how many sundays any given year has.

Reference no: EM131102826

Questions Cloud

How does dilemma represent an issue of justice : Briefly explain how this ethical dilemma can be viewed from the four paradigms - How does this dilemma represent an issue of justice?
Develop and practice public speaking skills : Your first formal speech is designed to help you develop and practice public speaking skills. Choose a topic that you know a lot about, have enthusiasm for, and can make interesting to a college audience (both men and women).
What is the international accounting standards board : What stakeholders might benefit from the use of International Accounting Standards?
Should the firm make the change? : Should the firm make the change? Would the firm's operating leverage increase or decrease if it made the change? What about its breakeven point? Would the new situation expose the firm to more or less business risk than the old one?
Design a function that takes two parameters : Length of a Month Design a function that takes two parameters: year and month, and returns an integer indicating how many days long that month is. January 2009 was 31 days long, February 2009 was 28 days long, February 2008 was 29 days long, and s..
Determine the unit impulse response of the filter : Check your result against the appropriate special case of Example 6.9.
Describe disadvantages of the education system : What is the "lemon" dance" and how is it related to tenure - what organization is the largest adversary to policy change in education and why?
Be an argument proving that monstresor : Read Poe's, "The Cask of Amontillado" and at least three scholarly articles about the story. Write and submit a 2,000 word essay in which you cite the research in order to convince your reader of your understanding of the story.
How you would design administer and evaluate the training : Design a one-day training program, based on this description, making assumptions when necessary to fill in the details. You should choose at least two different training methods, explaining why you chose each for this training topic and audience.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Steps necessary for improving and maintaining relations

Describe the steps necessary for improving and maintaining relations with other business units - Can you provide the answer with reference to basic computer science?

  Discuss key points of the team''s individual papers

Differentiate among the different kinds of torts that might affect a business.

  Find the standard deviation of the random variable x

Find the standard deviation of the random variable X.

  Cloud technology and virtualization

With the merger of your company with a multinational company, you have come to realize that progressive solutions are necessary to defray some of the associated information technology costs

  How protocols support business processes

Define upper layer applications.Explain how the application layer manages distributed applications and their protocols.Describes the application protocols associated with these services

  Dimensional array prime

Write a function TRANSFERP( int ALL[ ], int N) , to transfer all the prime numbers from a one dimensional array ALL[ ] to another one dimensional array PRIME[ ]. The resultant array PRIME[ ] must be displayed on screen.

  Information assets to estimate for risk management

If organization has three information assets to estimate for risk management as shown in accompanying data, which vulnerability must be evaluated for additional controls first?

  Discuss the issues of encryption and key management

Discuss the issues of encryption and key management in cloud computing, how it different for personal computers and traditional enterprising computing environments.(1300-1400 words)

  How of the concepts affected data communication

For Each topic write 2 paragraphs, with the first paragraph explaining the topic and the second paragraph answering the following questions: How of the concepts affected data communication in the past? What about the Future? Will these concepts..

  Determines the total due including sales tax and shipping

Create an application that determines the total due including sales tax and shipping. Allow the user to input any number of item prices. Sales tax of 7.75% is charged against the total purchases.

  Write a regular expression that selects lines

These letters may appear in uppercase as well. For this exercise you must surround your solution with double quotes .

  Calculate the total time required to transfer a 1000-kb file

The bandwidth is infinite, and during the first RTT we can send one packet (21-1 ), during the second RTT we can send two packets (22-1 ), during the third we can send four (23-1 ), and so on. (A justification for such an exponential increase will..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd