Question

SIGNS = '03,21-04,19=ARI;04,20-05,20=TAU;05,21-06,21=GEM;06,22-07,22=CAN;' + \ '07,23-08,22=LEO;08,23-09,22=VIR;09,23-10,23=LIB;10,24-11,20=SCO;' + \ '11,21-12,21=SAG;12,22-01,20=CAP;01,21-02,21=AQU;02,22-03,20=PIS;' def find_astrological_sign(month, date

SIGNS = '03,21-04,19=ARI;04,20-05,20=TAU;05,21-06,21=GEM;06,22-07,22=CAN;' + \
'07,23-08,22=LEO;08,23-09,22=VIR;09,23-10,23=LIB;10,24-11,20=SCO;' + \
'11,21-12,21=SAG;12,22-01,20=CAP;01,21-02,21=AQU;02,22-03,20=PIS;'

def find_astrological_sign(month, date):
'''
(int, int) -> str
  
Given two int values representing a month and a date, return a
3-character string that gives us what star sign a person born in that
month and on that date belongs to. Use the SIGNS string (already
defined for you at the top of this file) to figure this out.

NOTE FROM BOB: A lot of string slicing to do here. It looks like the
information for each sign is exactly 16 characters long.
We can probably use that.

>>> find_astrological_sign(8, 24)
'VIR'

>>> find_astrological_sign(1, 15)
'CAP'
'''

HOW TO WRITE THE CODE FOR THIS FUNCTION?

THE CODE NEED TO BE AS CLEAR AS POSSIBLE. THANK YOU

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def find_astrological_sign(month, date):
    astro_sign = ""
    if month == 1:
        if (date < 20):
            astro_sign = "CAP"
        else:
            astro_sign = "AQU"
    elif month == 2:
        if (date < 19):
            astro_sign = "AQU"
        else:
            astro_sign = "PIS"
    elif month == 3:
        if (date < 21):
            astro_sign = "PIS"
        else:
            astro_sign = "ARI"
    elif month == 4:
        if (date < 20):
            astro_sign = "ARI"
        else:
            astro_sign = "TAU"
    elif month == 5:
        if (date < 21):
            astro_sign = "TAU"
        else:
            astro_sign = "GEM"
    elif month == 6:
        if (date < 21):
            astro_sign = "GEM"
        else:
            astro_sign = "CAN"
    elif month == 7:
        if (date < 23):
            astro_sign = "CAN"
        else:
            astro_sign = "LEO"
    elif month == 8:
        if (date < 23):
            astro_sign = "LEO"
        else:
            astro_sign = "VIR"
    elif month == 9:
        if (date < 23):
            astro_sign = "VIR"
        else:
            astro_sign = "LIB"
    elif month == 10:
        if (date < 23):
            astro_sign = "LIB"
        else:
            astro_sign = "SCO"
    elif month == 11:
        if (date < 22):
            astro_sign = "SCO"
        else:
            astro_sign = "SAG"
    elif month == 12:
        if (date < 22):
            astro_sign = "SAG"
        else:
            astro_sign = "CAP"
    return astro_sign


#Testing
print(find_astrological_sign(8,24))
print(find_astrological_sign(1,15))

VIR
CAP

Add a comment
Know the answer?
Add Answer to:
SIGNS = '03,21-04,19=ARI;04,20-05,20=TAU;05,21-06,21=GEM;06,22-07,22=CAN;' + \ '07,23-08,22=LEO;08,23-09,22=VIR;09,23-10,23=LIB;10,24-11,20=SCO;' + \ '11,21-12,21=SAG;12,22-01,20=CAP;01,21-02,21=AQU;02,22-03,20=PIS;' def find_astrological_sign(month, date
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT