Question

In PYTHON, Write a function formatLongDate that will accept a date in the form mm/dd/yy as...

In PYTHON,

Write a function formatLongDate that will accept a date in the form mm/dd/yy as a string argument. Your program should take the string apart (hint: use an appropriate string function) into month, day and year variables. Return the date in the long format (e.g. 09/30/05 would be output as September 30, 2005). You may assume all years yy are in the 21st century. For instance:

>>> formatLongDate("09/05/99")

September 5, 2099

September 5, 2099

Homework Answers

Answer #1
def formatLongDate(s):
    lst = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    values = s.split("/")
    month = lst[int(values[0])-1]
    day = values[1]
    year = "20"+values[2]
    return month+" "+day+", "+year

# Testing
print(formatLongDate("09/05/99"))

September 05, 2099

Know the answer?
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
Similar Questions
Python homework. Write a function that takes as input a string that stores date and time...
Python homework. Write a function that takes as input a string that stores date and time (24-hour clock) in the following format: “MM/DD/YYYY HR:MIN:SEC” and prints the following: DD/MM/YYYY HR:MIN:SEC MM/YYYY Whether the time is a.m. or p.m. Validation of the input in the function is necessary.
Write a Python program that reads in the month, day, and year of a date and...
Write a Python program that reads in the month, day, and year of a date and prints it in the dd/mm/yyyy format or mm/dd/yyyy format, the format depending on the user’s preference. The program also prints the message It is a magic date If the product of month and day is equal to the last two digits of the year. For example, April 20 1980 is a magic date because April (numeric value 4) multiplied by 20 is equal to...
Please read the requirements: Write a C++ function, date, that will accept a date via a...
Please read the requirements: Write a C++ function, date, that will accept a date via a parameter in the month-day-year format, mmddyyyy, (e.g., 10262020 stands for the date October 26, 2020), and then will determine the corresponding month number, day, and year of that date, returning these three integer values to the calling function via arguments. An example of a call to the function date is shown in the following statement: date (10262020, month, day, year); This call to the...
Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them...
Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them on how to make good ones. In this lab you will write a program that accepts a date in the form “month/day/year” and prints whether or not the date is valid. For example 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.) Your program, in order to be correct, should be able to pass these simple (but far from complete!) test...
Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later...
Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should report the West basin elevationfor all days in the interval in the reverse chronological order (from the later date to the earlier). Example: $ ./reverse-order Enter earlier date: 05/29/2018 Enter later date: 06/02/2018 06/02/2018 590.22 ft 06/01/2018 590.23 ft 05/31/2018 590.24 ft 05/30/2018 590.26 ft 05/29/2018 590.32 ft Hint: If for the previous tasks you did not use arrays, here...
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter...
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter feeds. At a high level, your program is going to perform the following: Read in two files containing twitter feeds. Merge the twitter feeds in reverse chronological order (most recent first). Write the merged feeds to an output file. Provide some basic summary information about the files. The names of the files will be passed in to your program via command line arguments. Use...