Question

In: Computer Science

Write a program in date_generator.py that generates all the dates of next year in mmm dd,...

Write a program in date_generator.py that generates all the dates of next year in mmm dd, yyyy format, as shown below. You need not calculate whether 2021 is a leap year--it is NOT.

If you want to see a hint, scroll WAY down!

Jan 1, 2021
Jan 2, 2021
Jan 3, 2021
.
.
.
Dec 30, 2021
Dec 31, 2021

***my teachers hint:My solution to this program is quite short, but the code is not super simple. I used two lists, a for-loop nested inside another for-loop, range and enumerate.

Please do this in python

Solutions

Expert Solution

Code:

year=2021
months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
#list for months
days=[31,28,31,30,31,30,31,31,30,31,30,31]
#list for days in that particular month
for i in range(12):
#This loop iterates 12 times from 0 to 11
for j in range(1,days[i]+1):
#This loop iterates for days in that partivular month
print("{} {}, {}".format(months[i],j,year))#Here we print the mmm day, year
  

Output:

.

.

.

.

.

.

.

Indentation:


Related Solutions

Write a program that randomly generates 100 dates and store them into a vector. Use the...
Write a program that randomly generates 100 dates and store them into a vector. Use the Date.h provided . The dates generated must be within 1000 days after 1/1/2000. and Sort the 100 dates generated in ascending order. date.h #ifndef DATE_H_ #define DATE_H_ #include #include using namespace std; class Date {    friend ostream &operator<<( ostream &, const Date & ); private:    int day;    int month;    int year; static const int days[]; // array of days per...
Write a c++ program that randomly generates 100 dates, store them into four vectors of date...
Write a c++ program that randomly generates 100 dates, store them into four vectors of date objects according to their seasons.. The dates generated must be within 1000 days after 1/1/2000.
Question 1:Write a program that randomly generates 100 dates and store them into a vector. Use...
Question 1:Write a program that randomly generates 100 dates and store them into a vector. Use the Date class provided . The dates generated must be within 1000 days after 1/1/2000. Question 2:Sort the 100 dates generated in Question 1 in ascending order. This is Class data.h.(Please don't change the data.h file) data.h #ifndef DATE_H_ #define DATE_H_ #include #include using namespace std; class Date {    friend ostream &operator<<( ostream &, const Date & ); private:    int day;   ...
Write a program that generates and prints out in a neat format all possible truth tables...
Write a program that generates and prints out in a neat format all possible truth tables with three propositional variables p, q, and r. Your program should also number generated truth tables and output the numbers so it is clear how many total tables were generated. Your program output may look like the following (Note: only the beginning of the output is shown): Truth table 1: p q r proposition ----------------- F F F F F F T F F...
Write a program that generates all prime numbers between 2 and 1000, using the Sieve of...
Write a program that generates all prime numbers between 2 and 1000, using the Sieve of Eratosthenes method. You can find many articles that describe the method for finding primes in this manner on the Internet. Display all the prime values. This program should be in assembly language.
C++ Write a function called gen_dates() that generates random dates. It takes two arrays of integers...
C++ Write a function called gen_dates() that generates random dates. It takes two arrays of integers called months and days to store the month and day of each date generated, a constant array of 12 integers called num_of_days that specify the number of days of each of the 12 months and an integer called size that specifies how many dates to generate and randomly generates size dates, storing the generated months in months array and generated days in days array....
C++ DO not use arrays to write this program. Write a program that repeatedly generates three...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three random integers in the range [1, 100] and continues as follows: If the right-most digit of all the three integers is equal, the program displays them in ascending order on the screen and continues. If the generated integers have different right-most digits, they are not displayed and the program continues. The program terminates once the right-most digits of all the three random numbers are...
PYTHON    Generates a list of datetimes given a list of dates and a list of...
PYTHON    Generates a list of datetimes given a list of dates and a list of times. All possible combinations of date and time are contained within the result. The result is sorted in chronological order. For example, Input: >>> timetable([date(2019,9,27), date(2019,9,30)], [time(14,10), time(10,30)]) Output: [datetime(2019,9,27,10,30), datetime(2019,9,27,14,10), datetime(2019,9,30,10,30), datetime(2019,9,30,14,10)] Current code: from datetime import date, time, datetime def timetable(dates, times): lis = []    for c in times: for y in dates: x = f"(datetime{y},{c})" lis.append(x) #doesn't work at all
Write a program compare.cpp that asks the user to input two dates (the beginning and the...
Write a program compare.cpp that asks the user to input two dates (the beginning and the end of the interval). The program should check each day in the interval and report which basin had higher elevation on that day by printing “East” or “West”, or print “Equal” if both basins are at the same level. Example: $ ./compare Enter starting date: 09/13/2018 Enter ending date: 09/17/2018 09/13/2018 West 09/14/2018 West 09/15/2018 West 09/16/2018 West 09/17/2018 West Explanation: Date East (ft)...
*Write in C* Write a program that generates a random Powerball lottery ticket number . A...
*Write in C* Write a program that generates a random Powerball lottery ticket number . A powerball ticket number consists of 5 integer numbers ( between 1-69) and One power play number( between 1-25).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT