Create Quarters

Create Quarters

Ms. Ann wants her students to understand about tuples in Python.  She wanted them to create a tuple  with the name ‘months’  which should contain the name of all 12 months.    She also wanted them to slice this tuple into four quarters :  January – March, April – June, July – September and October – December.  Store these quarters into 4 different tuples and display all the tuples as specified in the sample output.    

Sample output:
Months in expanded form:                                                       
January                                                                        
February                                                                       
March                                                                          
April                                                                          
May                                                                            
June                                                                           
July                                                                           
August                                                                         
September         
October
November
December

The four quarters are:

First Quarter :
January
February
March

Second Quarter :
April
May
June

Third Quarter :
July
August
September

Fourth Quarter :
October
November
December

Code :-

m=('January','February','March','April','May','June','July','August'
,'September','October','November','December')
print("Months in expanded form:")
for i in m:
    print(i)
print()
print("The four quarters are:")
print()
print("First Quarter :")
for i in m[:3]:
    print(i)
print()
print("Second Quarter :")
for j in m[3:6]:
    print(j)
print()
print("Third Quarter :")
for k in m[6:9]:
    print(k)
print()
print("Fourth Quarter :")
for l in m[9:12]:
    print(l)

2 thoughts on “Create Quarters”

  1. An added important issue is that if you are an older person, travel insurance with regard to pensioners is something that is important to really look at. The mature you are, the greater at risk you’re for allowing something undesirable happen to you while in most foreign countries. If you are certainly not covered by many comprehensive insurance coverage, you could have a few serious troubles. Thanks for discussing your advice on this blog site.

Leave a Comment

Your email address will not be published. Required fields are marked *

x