Ask Question

Problem 1: Create a list that contains the months of the year. Problem 2: Create a loop to print the month number and name (do not hard code the month number)

+3
Answers (1)
  1. 16 August, 10:28
    0
    Program for problem 1:

    Month_name=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] # List which holds the month name.

    Program for problem 2:

    Month_name=['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] # List which holds the month name.

    for x in range (0,12) : # loop which is used to print the name and number of the month.

    print (str (x+1) + " "+Month_name[x]) # It will print the number and month name.

    Output of problem 1:

    The program for problem 1 has no output because it has no print statement.

    Output of problem 2:

    The above program will print all the months with their number in which the first text will print the number of the month and the second text will print the name of the month.

    Explanation:

    Missing information:

    "Design the program for problem 1 and problem 2" is missing on the above question.

    Detailed Explanation:

    The above program is in python language in which the first line creates a list of the names of the months. Then the "for loop" is used to print the number and name of the program. In this "for loop", the list index is printed by adding 1 on it with the value which is the name of the month. It is because the list starting index value is 0 and the ending index value is size-1.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Problem 1: Create a list that contains the months of the year. Problem 2: Create a loop to print the month number and name (do not hard ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers