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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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