Question

Must be in Python Programming Project 8 The ISO 8601 Standard date format for Information Interchange...

Must be in Python

Programming Project 8

The ISO 8601 Standard date format for Information Interchange indicates that a date be written as such:

                        YYYY-MM-DD

You are to write a program which converts dates for the user. The program allows a user to choose between:

* Enter a date in the business format   DD-MMMM-YYYY   (eg. 06-SEPT-2015 ) . The program will then print out the ISO 8601 representation of the date   (2015-09-06).

* Enter a date in ISO 8601 format (eg 2018-12-12), and print out the date in business format (12-DEC-2018)

Your program should handle user input errors such as:

* leading blanks

* blanks within the input string

Your program should delegate any large operations to functions which should be DEFINED AN IMPORTED MODULE

eg.) month conversion

Be sure you program contains a comment indicating your name, plus comments within the program indicating what is is happening. Each line does not need to be commented, just each group of lines that are completing a specific task.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::

def printMenu():
print("Enter following choice")
print("1. to convert date from business format to ISO 8601 representation")
print("2. to convert date from ISO 8601 representation format to business")
print("3. to exit")
  
def monthConversion(monthIn,mode):
month = ["JAN", "FEB", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUG", "SEPT", "OCT", "NOV", "DEC"]
convt = ["01","02","03","04","05","06","07","08","09","10","11","12"]
if mode==1:
for i in range(12):
if month[i]==monthIn:
return convt[i]
elif mode==2:
for i in range(12):
if int(convt[i])==int(monthIn):
return month[i]
  
  
def convertDate(date,mode):
if mode==1:
dates = date.split("-")
dd = dates[0]
mmmm = dates[1]
yyyy = dates[2]
newMonth=monthConversion(mmmm,mode)
return yyyy+"-"+newMonth+"-"+dd
elif mode==2:
dates = date.split("-")
dd = dates[2]
mmmm = dates[1]
yyyy = dates[0]
newMonth=monthConversion(mmmm,mode)
return dd+"-"+newMonth+"-"+yyyy
  
  
if __name__ == '__main__':
while True:
printMenu()
choice = input("Enter your choice : ")
if choice=="1":
date = input("Enter date in business format DD-MMMM-YYYY (eg. 06-SEPT-2015 ) : ")
#replace space with ""
date = date.replace(" ", "")
conDate=convertDate(date,1)
print("Date in ISO 8601 representation is : "+conDate)
elif choice=="2":
date = input("Enter date in ISO 8601 format (eg 2018-12-12) : ")
#replace space with ""
date = date.replace(" ", "")
conDate=convertDate(date,2)
print("Date in business format : "+conDate)
elif choice=="3":
break
else:
print("Please enter valid choice")
  

output:

Add a comment
Know the answer?
Add Answer to:
Must be in Python Programming Project 8 The ISO 8601 Standard date format for Information Interchange...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need this in Java, please! The ISO 8601 Standard date format for Information Interchange indicates...

    I need this in Java, please! The ISO 8601 Standard date format for Information Interchange indicates that a date be written as such: yyyy-MM-dd (eg. 2012-07-02, 1999-12-05, 1998 -01-27 ) where yyyy represents the four digit year MM represents a two digit numerical month dd represents a two digit numerical day Chinese date format is specified as: yyyy-M-d Macedonean date format is specified as: d.M.yyyy where yyyy represents the four digit year M represents a one or two digit numerical...

  • Python 3. Date Printer Write a program that reads a string from the user containing a...

    Python 3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018 3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018

  • Write a program that reads a string from the user containing a date in the form...

    Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018   I am asking for help in basic python please

  • Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program...

    Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program should use a single input statement to accept the date, storing each piece of the date into an appropriate variable. Demonstrate that the input was obtained correctly by outputting the month, day, and year to the screen. Sample output: Enter (date (mm/dd/yyyy): 02/08/2011 Month entered: 2 Day entered: 8 Year entered: 2011 Challenge: Although the user entered 02, C++ drops the 0 as insignificant...

  • IN PYTHON, Write a program that reads a string from the user containing a date in...

    IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.

  • PYTHON Build a regular expressions based on informal specifications to match specified patterns. Use a compiled...

    PYTHON Build a regular expressions based on informal specifications to match specified patterns. Use a compiled regular expression in a Python program where appropriate. Use Python's text processing str methods to generate a string format converter. create a date format converter. Your program will convert a date in the format “mm/dd/yyyy” to the format “month day, year”. Specify the required input format: mm/dd/yyyy Use a regular expression to validate the user input date format. If the format is incorrect raise...

  • -make an ordered single linked list -straight to screen (no user prompting) -the date is format...

    -make an ordered single linked list -straight to screen (no user prompting) -the date is format mm dd yyyy, and must be imbedded in the program (no user prompting) -example must be able to work with code -comments above each action/line encouraged Design, implement and test a C++ program that reads a series of data records from a file and stores each record in a linked list (in ascending order by items number). After creating the linked list the program...

  • anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and...

    anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and begins at position x of anyString. Write a program that reads a string from the user containing a date in the format mm/dd/yyyy. You have to use above substring method to extract the various fields from the format. It should print the date in the form Month Date, Year. Validate:  Exit the program with error message as “Invalid date format” if length of...

  • In this exam, you will design and implement a Python class called 'Date according to the...

    In this exam, you will design and implement a Python class called 'Date according to the following API specifications. • Do NOT use any existing classes in your answer such as datetime. . You will design your class so that it operates correctly on another planet, where the total days in a year, total days in a month, and months per year may be different. For our planet Earth, you will assume that a year has 360 days and all...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT