Generating Calendar in Python

A 737-word essay, formatted in APA 7 (about 3 double-spaced pages).

Updated

Type
Essay
Length
737 words, 3 pages
Style
APA 7
Contents (2 sections)
  1. Solution
  2. Read More: – Generating Calendar in Python

EssayAPA 7

Generating Calendar in Python

This article provides a sample solution on Generating Calendar in Python Plus other Homework Solutions.

Permalink: https://studyinghq.com/essay-examples/generating-calendar-in-python

As you continue, thestudycorp.com has the top and most qualified writers to help with any of your assignments. All you need to do is place an order with us. (Generating Calendar in Python)

Solution

Homework 1:  Generate Calendar

 <pre>def calendar(n, s):

#this will convert string value to a corresponding integer

 if s == “Su”:

 d = 0

 elif s == “Mo”:

 d = 1

 elif s == “Tu”:

 d = 2

 elif s == “We”:

 d = 3

 elif s == “Th”:

 d = 4

 elif s == “Fr”:

 d = 5

 elif s == “Sa”:

 d = 6

 print (“Su Mo Tu We Th Fr Sa”)

 for j in range(d):

 print (” “, end = ” “),

 i = 1

 while i <= n:

 if i < 10:

 print (“”,i,end=” “),

 else:

 print(i,end=” “),

 if(i + d) % 7 == 0:

 print (” “)

 i = i + 1

n = int(input(“Input the number of days in the month (28-31): “))

s = input(“Input the starting day (Su=Sun, Mo=Mon,…): “)

calendar(n,s)</pre>

1b) Year 2020 Calendar

 # Program to display  2020 calendar and User to enter the specific month to display

# importing calendar module

import calendar

yy = 2020  # year

# To take month input from the user

 mm= int(input(“Enter year: “))

# display the calendar

print(calendar.month(yy, mm))

1c) A short program for January 2020 Calendar

    # Program to display  Jan 2020 calendar 

    # importing calendar module

    import calendar

    yy = 2020  # year

    mm = 1    #month

    # the header will be January 2020

    print(calendar.month(yy, mm))

2, loop over 30 days of September

 def date_iter(year, month):

    for i in range(1, calendar.monthlen(year, month) + 1):

        yield date(year, month, i)

      for d in date_iter(2020, 9):

      print(d)

As you continue, thestudycorp.com has the top and most qualified writers to help with any of your assignments. All you need to do is place an order with us. (Generating Calendar in Python)

Generating Calendar in Python
Generating Calendar in Python

b)  Genialize your calendar to 100 year

 days = [“su”, “mo”, “tu”, “we”, “th”, “fr”, “sa”]

months = [“January”, “February”, “March”, “April”, “May”,

“June”, “July”, “August”, “September”, “October”, “November”, “December”]

      old_length_s = 0

      length_current_month = 0

      month_header = “”

      title = “”

      data = dict()

      for year in range(startYear, endYear):

      s = “|”

      # data[year] = dict()

      for month in months:

    old_length_s = len(s)

    s += ” “

    # data[year][month] = dict()

    cal_data = subprocess.Popen(“cal ” + str(month) +

    ” ” + str(year),shell=True, stdout=subprocess.PIPE)

    week_loop = 0

    for line in iter(cal_data.stdout.readline, b””):

    if week_loop > 1: #this is after month name and day_names

      char_num = 0

      day = 0

      date = “”

      for c in line:

      date += c

      if char_num > 1: #every three characters

      char_num = 0

      if len(date.strip()) > 0: #somefields are blank in each month’s first week

      # data[year][month][int(date)] = days[day]

      if days[day] is “su”:

      if int(date) < 10:

      s += ” * “

      else:

      s += ” *  “

      else:

      s += ” ” + str(date.strip()) + ” “

    date = “”

      day += 1

      else:

      char_num += 1

      week_loop += 1

    # print len(s)

      if month is “February” and len(s) is 223:

      s += ”    “

      s += ” |”

    if first_year is True:

      length_current_month = len(s) – old_length_s

      blankspace = (length_current_month/2) – len(month)/2

      if len(month)%2 is not 0:

      month_header += ” “*blankspace + month + ” “*(blankspace-1)

As you continue, thestudycorp.com has the top and most qualified writers to help with any of your assignments. All you need to do is place an order with us. (Generating Calendar in Python)

Generating Calendar in Python
Generating Calendar in Python

      else:

      month_header += ” “*blankspace + month + ” “*blankspace

    if month is “June”:

    s += “|  ” + str(year) + ”  ||”

      month_header += ”            “

      actual_title = str(startYear) + ” to ” + str(endYear-1)

      title = ” “*((len(s)-7)-(len(actual_title)/2 -1 )) + actual_title

      # print s

    if first_year is True:

      first_year = False

      print(title)

      print(“\n”*5)

      print(month_header)

      print(“\n”*3)

      for c in s:

    if c is not “|”:

      dividing_line += “-“

      decade_divider += “=”

      else:

      dividing_line += c

      decade_divider += c

    if str(year)[-1] is “0”:

      print(decade_divider)

      print(“\n”)

      print(decade_divider)

      else:

    print(dividing_line)

      print(“\n”)

      print(s)

      print(“\n”)

    print(dividing_line)

      print(“\n”*2)

      print(“* = sunday”)

      print(“\n”*2)

      writer.close()

def Main():

    print

      startYear = int(sys.argv[1])

    year_interval = int(sys.argv[2])

      endYear = startYear + year_interval

      getDaysData(startYear, endYear)

Read More: – Generating Calendar in Python

https://studyinghq.com/essay-examples/scholarly-activity-summary-clinical-nurses-seminar/
https://studyinghq.com/essay-examples/capstone-project-change-proposal-example/

All Solved Essays

About the author

Dr. Wilson is a Health Care Writer, and content writer. He has an Ph. D. in public health and topical understanding of Nursing Practice.

More papers by this author

This paper is a sample from a completed student assignment, published to help you understand structure, argument and APA formatting. Use it for inspiration and reference only, and cite it if you quote it.

Get this paper as a Word file

generating-calendar-in-python.docx, with an APA title page and reference list, ready to edit in Word or Google Docs.

Need a custom paper on Generating Calendar in Python?

Get an original, plagiarism-free paper written to your rubric by a nursing expert.

Get Writing Help from $12 per page

Cite This Paper

Pick your style, then copy. Italics are kept when you paste into Word or Google Docs.

Reference list

๐Ÿ“• Studying HQ. (2022, April 11). Generating Calendar in Python [Essay example]. https://studyinghq.com/essay-examples/generating-calendar-in-python/

In-text

(๐Ÿ“• Studying HQ, 2022)

Published . Updated .

Cite this paper

Get the Word file

We'll email you generating-calendar-in-python.docx, formatted in APA and ready to edit.

We use your email to send this file, and offers only if you tick the box. Privacy policy

Get a paper like thisFrom $12 per page Get a price