Friday, September 16, 2016

Lab 2.6 and Lab 2

Lab 2.6

import datetime

def print_b_day_invitation(age,name,party_date,time,address,reply_date):
print ("\n")
print (datetime.date.today())
print ("\n")
print ("              "+str(age))
print ("        "+str(name)+"'s"+" "+"turning"+" "+str(age))
print ("Let's Celebrate with dinner and drinks")
print (str(party_date)+" | "+str(time)+" | "+str(address))
print ("     Kindly RSVP by "+str(reply_date))
print_b_day_invitation(26,"Emily","October 12","6pm","450 Williams Street","October 1")
print_b_day_invitation(80,"John","November 21","8pm","123 Oak Street","November 1")
print_b_day_invitation(51,"Mary","December 12","6:30pm","456 Maple Street","December 1")




Lab 2

Q1
import datetime
datetime.date.today()
print ( "Today's Date = "+str (datetime.date.today()))
def print_3rd_business_letter(your_name,your_address,recipient_name,title,company_address):
   print ("\n")
   print (your_name)
   print (your_address)
   print ("\n")
   print (datetime.date.today())
   print ("\n")
   print (recipient_name)
   print (title)
   print (company_address)
   print ("\n")
   print ("Dear "+ (recipient_name)+ ",")
   print ("")
   print ("This is the first paragraph. It is three sentences long. This is the last sentence.")
   print ("")
   print ("This is the second paragraph. It is three sentences long. This is the last sentence.")
   print ("")
   print ("Sincerely, ")
   print (your_name)
print_3rd_business_letter("Nicholas Benson","123 Fakestreet\nFakeville AL 35810","Clark Kent","Superman", "Fakestreet\nFakeville Al 35810")

Q2
#Day of the week for April 1, 1921#What Day of The Week Does 4 Mean?#Use a Date Object to Find A Function That Returns Today's Date#Find the Number of Days In Between Today And January 1, 1970import calendar
import datetime
import time
from datetime import date
def day_of_week(year, day_number, month):
   day_value = (calendar.weekday((year),(month),(day_number)))
   if day_value == 0:
      day="Monday"   if day_value == 1:
      day="Tuesday"   if day_value == 2:
      day="Wednesday"   if day_value == 3:
      day="Thursday"   if day_value == 4:
      day="Friday"   if day_value == 5:
      day="Saturday"   if day_value == 6:
      day="Sunday"   print (str(month)+"/ "+str(day_number)+"/ "+str(year) + " was on a "+(day))
   print ( "Today's Date = "+str (datetime.date.today()))
day_of_week((1921), (1), (4))
def day_difference():
   today = time.localtime()
   gmtimea = time.time()
   print ("The Difference of Days Between Today and January 1, 1970: ")
   print (int(gmtimea/86400))
day_difference()

No comments:

Post a Comment