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
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
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
SIGN_GROUPS = '[ARI,LEO,SAG]-[TAU,VIR,CAP]-[GEM,LIB,AQU]-[PIS,SCO,CAN]' def get_sign_group(sign): ''' (str) -> int Given a three character string representing a star sign, return which group (out of 0, 1, 2, or 3) this star sign belongs to. Use the SIGN_GROUPS string (already defined for you above) to figure out the group. i.e. As given by this string '[ARI,LEO,SAG]-[TAU,VIR,CAP]-[GEM,LIB,AQU]-[PIS,SCO,CAN]' the signs ARI, LEO and SAG are in group 0, the signs TAU, VIR, CAP are in group 1, and so on. >>> get_sign_group('ARI') 0 >>>...
SIGN_GROUPS = '[ARI,LEO,SAG]-[TAU,VIR,CAP]-[GEM,LIB,AQU]-[PIS,SCO,CAN]' def get_sign_group(sign): ''' (str) -> int Given a three character string representing a star sign, return which group (out of 0, 1, 2, or 3) this star sign belongs to. Use the SIGN_GROUPS string (already defined for you above) to figure out the group. i.e. As given by this string '[ARI,LEO,SAG]-[TAU,VIR,CAP]-[GEM,LIB,AQU]-[PIS,SCO,CAN]' the signs ARI, LEO and SAG are in group 0, the signs TAU, VIR, CAP are in group 1, and so on. >>> get_sign_group('ARI') 0 >>>...
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...
SIGN_GROUPS = '[ARI,LEO,SAG]-[TAU,VIR,CAP]-[GEM,LIB,AQU]-[PIS,SCO,CAN] def find_astrological_compatibility(sign_1, sign_2): ''' (str, str) -> int Given two 3-character strings representing star signs, return an int representing how compatible they are. According to Bob's rules, the compatibility between signs is calculated based on the SIGN_GROUPS they belong in, as follows: - If the signs are in the same group, return 100 - If both the signs are in an odd-numbered group (i.e. 1 and 3) OR if both are in an even group (i.e. 0...
Python help it is a grade 12 course
def find astrological sign(month, date): (int, int)-str Given two int values represent ing 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...