Question

def find astrological sign(month, date): (int, int)-str Given two int values represent ing a month and a date, return a 3-cha

# NOTE FROM BOB: DO NOT EDIT THIS STRING # SIGNS is a string representing the start and end date of each sign # Each star sig

Python help it is a grade 12 course

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

SIGNS='03,21-04,17=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):

dates=SIGNS.split(";")#split the sign with ; delimeter

for d in dates:
#fetching the starting month from the string
strtMonth=d[:d.find(",")]
d=d[d.find(",")+1:]
#fetching the starting date from the string
startDate=d[:d.find("-")]
d=d[d.find("-")+1:]
#fetching the ending month from the string
endMonth=d[:d.find(",")]
d=d[d.find(",")+1:]
#fetching the ending date from the string
endDate=d[:d.find("=")]
d=d[d.find("=")+1:]
#fetching the sign
sign=d

if(month==int(strtMonth)):
if(date>=int(startDate)):
return sign
if(month==int(endMonth)):
if(date<=int(startDate)):
return sign

print("For the month 8th and date 2 astrology sign is: ",find_astrological_sign(8,24))
print("For the month 1st and date 15 astrology sign is: ",find_astrological_sign(1,15))

output

snap of code for indent

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Python help it is a grade 12 course def find astrological sign(month, date): (int, int)-str Given...
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