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 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++ 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...
*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).
this has to be coded in c ++ • Write a program which generates a DIFFERENT...
this has to be coded in c ++ • Write a program which generates a DIFFERENT random number between 1 and 100 everytime you run the program. Please go online and see how poeple are trying to solve this. You can submit their code. Make sure you include a comment which shows from where the code was taken. You do not need to understand the code but if you can, thats great. This program will be used in the upcoming...
Given a list of items, write a program that generates a list of lists of the...
Given a list of items, write a program that generates a list of lists of the following form: [a,b,c,...,z]⇒[[z], [y,z], [x,y,z], ... , [a,b, ... ,y,z]] Hint: Slicing is your friend. please write a python program
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If...
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If the age is greater than 21 print "welcome," and if the age is less than 21 print "sorry." Use input validation to make sure the birthdate was entered correctly.
Write a program that generates a random number in the range of 1 through 100, and...
Write a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. When the number is generated by the computer, don’t display the number to the user, but only display if the number generated is odd or even. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the...
Write a program that generates a random number in the range of 1 through 100, and...
Write a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. When the number is generated by the computer, don’t display the number to the user, but only display if the number generated is odd or even. If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT