The male gametes or sperm cells in humans and other mammals are heterogametic and contain one of two types of sex chromosomes. They are either X or Y. The female gametes or eggs however, contain only the X sex chromosome and are homogametic.

The sperm cell determines the sex of an individual in this case. If a sperm cell containing an X chromosome fertilizes an egg, the resulting zygote will be XX or female. If the sperm cell contains a Y chromosome, then the resulting zygote will be XY or male.

Determine if the sex of the offspring will be male or female based on the X or Y chromosome present in the male's sperm.

If the sperm contains the X chromosome, return "Congratulations! You're going to have a daughter.";
If the sperm contains the Y chromosome, return "Congratulations! You're going to have a son.";

Difficulty: introductory

Starter code:

def chromosome_check(sperm):
	

Solutions:
def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a {}.'.format('son' if 'Y' in sperm else 'daughter')

def chromosome_check(sperm):
    gender = {"XY" : "son", "XX" : "daughter"}
    
    return "Congratulations! You're going to have a {}.".format(gender[sperm])

def chromosome_check(sperm):
    return "Congratulations! You're going to have a %s." % ('son', 'daughter')[sperm[1] == 'X']

def chromosome_check(sperm):
    gender = 'son' if 'Y' in sperm else 'daughter'
    return f"Congratulations! You're going to have a {gender}."

def chromosome_check(sperm):
    return f'Congratulations! You\'re going to have a {"son" if sperm == "XY" else "daughter"}.'

def chromosome_check(sperm):
    return "Congratulations! You're going to have a {}.".format({"XY": "son", "XX": "daughter"}.get(sperm)) 

def chromosome_check(sperm):
    gender = 'son' if 'Y' in sperm else 'daughter'
    return "Congratulations! You're going to have a {}.".format(gender)

def chromosome_check(sperm):
    d = 'Congratulations! You\'re going to have a daughter.'
    s = 'Congratulations! You\'re going to have a son.'
    return s if sperm.find("Y") == 1 else d

def chromosome_check(s):
    return "Congratulations! You're going to have a %s." % ("son" if s[1] == 'Y' else "daughter")

def chromosome_check(sperm):
    # Sperm analysis also requires programming...Yeah. I know. Still I can't help rofling
    if all(i == sperm[0] for i in sperm):
        return 'Congratulations! You\'re going to have a daughter.'
    return 'Congratulations! You\'re going to have a son.'
    


def chromosome_check(sperm):
    return f"Congratulations! You're going to have a {'son' if 'Y' in sperm else 'daughter'}."

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a {}.'.format('daughter' if sperm == 'XX' else 'son')


def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a %s.' %('daughter' if sperm[-1] == 'X' else 'son')

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a son.' if  sperm.find('Y') !=-1 else 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    if 'Y' in sperm: return "Congratulations! You're going to have a son."
    return "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    if sperm == "XY":
        return("Congratulations! You're going to have a son.")
    else:
        return("Congratulations! You're going to have a daughter.")

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a son.' if sperm == 'XY' else 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    return f"Congratulations! You\'re going to have a {['daughter','son']['Y' in sperm]}."


def chromosome_check(sperm):
    if sperm == "XX":
        return "Congratulations! You're going to have a daughter."
    else:
        return "Congratulations! You're going to have a son." 
        
# Can I just point out that gametes only have one set of chromosomes so the sperm would have 'X' or 'Y' not 'XX' or 'XY'


def chromosome_check(sperm):
    congrats = "Congratulations! You're going to have a " 
    return congrats + "son." if "Y" in sperm else congrats + "daughter."


chromosome_check = lambda sperm: 'Congratulations! You\'re going to have a {}.'.format("son" if "Y" in sperm else "daughter")

def chromosome_check(sperm):
    return "Congratulations! You're going to have a {}".format( 'son.' if "Y" in sperm else "daughter.")

def chromosome_check(sperm: str) -> str:
    """ Determine if the sex of the offspring based on the X or Y chromosome present in the male's sperm. """
    return f"Congratulations! You\'re going to have a {'son' if sperm == 'XY' else 'daughter'}."

chromosome_check = {'XY':'Congratulations! You\'re going to have a son.', 'XX':'Congratulations! You\'re going to have a daughter.'}.get

chromosome_check=lambda s: "Congratulations! You\'re going to have a daughter." if s=="XX" else "Congratulations! You\'re going to have a son."

def chromosome_check(sperm):
    return('Congratulations! You\'re going to have a son.','Congratulations! You\'re going to have a daughter.')[sperm=='XX']

chromosome_check=lambda s:"Congratulations! You're going to have a %s."%["daughter","son"]["Y"in s]

def chromosome_check(sperm):
    #Your code here
    sex = ["Congratulations! You\'re going to have a daughter.", "Congratulations! You\'re going to have a son."]
    return (sex["Y" in sperm])

def chromosome_check(sperm):
    text = 'Congratulations! You\'re going to have a '
    return text + ('son.', 'daughter.')[sperm == 'XX']

def chromosome_check(sperm):
    gender = "son" if sperm[-1] == "Y" else "daughter"
    return f"Congratulations! You're going to have a {gender}."

def chromosome_check(sperm):
    return f"Congratulations! You're going to have a {'son' if sperm[1] == 'Y' else 'daughter'}."

def chromosome_check(sperm):
    if "XY" in sperm:
        return 'Congratulations! You\'re going to have a son.'
    elif "XX" in sperm:
        return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    ergebnis=''
    if sperm=='XY':
        ergebnis='Congratulations! You\'re going to have a son.'
    else:
        ergebnis='Congratulations! You\'re going to have a daughter.'
    return ergebnis    

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a son.' if 'y' in sperm.lower() else\
            'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    return "Congratulations! You're going to have a daughter." if sperm[0] == sperm[1] \
        else "Congratulations! You're going to have a son."

def chromosome_check(sperm):
    return "Congratulations! You're going to have a {}.".format({"XY":"son","XX":"daughter"}[sperm])

def chromosome_check(s):
    return "Congratulations! You\'re going to have a daughter." if s=='XX' else "Congratulations! You\'re going to have a son."

def chromosome_check(sperm):
    offspring = "son" if "Y" in sperm else "daughter"
    return f"Congratulations! You're going to have a {offspring}."

def chromosome_check(sperm):
    gen = "son" if "Y" in sperm else "daughter"
    return f"Congratulations! You're going to have a {gen}."


def chromosome_check(sperm):
    count = 0
    for i in sperm:
        if i == 'Y':
            count += 1
    if count == 1:
        return 'Congratulations! You\'re going to have a son.'
    else:
        return 'Congratulations! You\'re going to have a daughter.'


def chromosome_check(sperm):
    sperm_list = list(sperm)
    if sperm_list[0] == sperm_list[1]:
        return 'Congratulations! You\'re going to have a daughter.'
    return 'Congratulations! You\'re going to have a son.'

def chromosome_check(sperm):
    if sperm[-1] == 'Y':
        return 'Congratulations! You\'re going to have a son.'
    return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    #Your code here
    if sperm[0:2] == "XY":
        return 'Congratulations! You\'re going to have a son.'
    if sperm[0:2] == "XX":
        return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    k = 'son' if 'Y' in sperm else 'daughter' 
    return  f'''Congratulations! You're going to have a {k}.'''
#Your code here


def chromosome_check(sperm):
    sex = 'son' if 'Y' in sperm else 'daughter'
    return f'Congratulations! You\'re going to have a {sex}.'

def chromosome_check(sperm):
    if 'Y' in sperm:
        return 'Congratulations! You\'re going to have a son.' 
    if not 'Y' in sperm: 
        return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    return f"Congratulations! You\'re going to have a {'son' if sperm[1] == 'Y' else 'daughter'}."

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a '+{'XX':"daughter.","XY":"son."}[sperm]

def chromosome_check(s):
    if s=="XX": return "Congratulations! You\'re going to have a daughter."
    if s=="XY":return "Congratulations! You're going to have a son."

def chromosome_check(sperm):
    if sperm == "XX":
        result = 'Congratulations! You\'re going to have a daughter.'
    else:
        result = 'Congratulations! You\'re going to have a son.'
    return result


def chromosome_check(sperm):
    if sperm == "XY":
        return 'Congratulations! You\'re going to have a son.'
    elif sperm == "XX":
        return 'Congratulations! You\'re going to have a daughter.'
    else:
        return 'Congratulations! You\'re going to have a daughter.'


def chromosome_check(sperm):
    if sperm=="XY":
        return "Congratulations! You\'re going to have a son."
    elif sperm=="XX":
        return "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    template = "Congratulations! You're going to have "
    if 'Y' in sperm:
        return template + 'a son.' 
    else:
        return template + 'a daughter.'

def chromosome_check(sperm):
    res = ['son', 'daughter'][sperm == 'XX']
    return f'Congratulations! You\'re going to have a {res}.'

def chromosome_check(sperm):
    if sperm[0] == 'X' and sperm[1] == 'X':
        return 'Congratulations! You\'re going to have a daughter.'
    elif sperm[0] == 'X' and sperm[1] == 'Y':
        return 'Congratulations! You\'re going to have a son.'


chromosome_check=lambda x:"Congratulations! You're going to have a son." if 'Y' in x else "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    gender = {"XY" : "son", "XX" : "daughter"}
    return f"Congratulations! You're going to have a {gender[sperm]}."

# Determine if the offspring will be male or female based on the X or Y chromosome present in the male's sperm.

# XX = Female
# XY = Male
def chromosome_check(sperm):
    if sperm == 'XY': return 'Congratulations! You\'re going to have a son.'
    else: return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    sex = 'son' if sperm[1] == 'Y' else 'daughter'
    return f"Congratulations! You're going to have a {sex}."

def chromosome_check(sperm):
    "Wye Ask Wye, Ask Bud Drye"
    return 'Congratulations! You\'re going to have a {}.'.format("son" if sperm=="XY" else "daughter")

def chromosome_check(sperm):
    return "Congratulations! You\'re going to have a {}.".format(["son", "daughter"][sperm.count("X")-1])

def chromosome_check(sperm):
    return  'Congratulations! You\'re going to have a {}.'.format(('son','daughter')['X'==sperm[1]])

def chromosome_check(sperm):
    b = 'Congratulations! You\'re going to have a son.'
    g = 'Congratulations! You\'re going to have a daughter.'
    if sperm == 'XY':
        return b
    else:
        return g

def chromosome_check(sperm):
    if "XY" == sperm:
        return 'Congratulations! You\'re going to have a son.'
    if "XX" == sperm:
        return 'Congratulations! You\'re going to have a daughter.'

def chromosome_check(sperm):
    if "X" and "Y" in sperm:
        return 'Congratulations! You\'re going to have a son.'
    else:
       return 'Congratulations! You\'re going to have a daughter.'

Kind_sperm = {'XY':"Congratulations! You're going to have a son.",\
    'XX':"Congratulations! You're going to have a daughter."}
def chromosome_check(sperm):
    if sperm in Kind_sperm.keys():
        return Kind_sperm[sperm]

def chromosome_check(sperm):
    msg = 'Congratulations! You\'re going to have a '
    child = ('daughter.','son.')['Y' in sperm]
    return msg + child

def chromosome_check(sperm):
    kid = 'son' if 'Y' in sperm else 'daughter'
    return f'Congratulations! You\'re going to have a {kid}.' 

def chromosome_check(sperm):
    return "Congratulations! You're going to have a daughter." if 'X' == sperm[-1] else "Congratulations! You're going to have a son."

def chromosome_check(sperm):
    da = "Congratulations! You're going to have a daughter."
    so = "Congratulations! You're going to have a son."
    
    return so if "Y" in sperm else da

def chromosome_check(sperm):
    off_spring = {'XY': 'Congratulations! You\'re going to have a son.', 'XX':'Congratulations! You\'re going to have a daughter.'}
    return off_spring[sperm]
    #Your code here


def chromosome_check(sperm):
    return "Congratulations! You're going to have a son." if sperm != "XX" else "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    if sperm == "XX": 
        return "Congratulations! You're going to have a daughter."
    if sperm == "XY" or "YX":
        return "Congratulations! You're going to have a son."


def chromosome_check(sperm):
    if sperm == "XY":
        return "Congratulations! You're going to have a son."
    else:
        sperm == "XX"
        return "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    if sperm == "XY":
        return f"Congratulations! You\'re going to have a son."
    return f"Congratulations! You\'re going to have a daughter."

def chromosome_check(sperm):
    gender = {"XX": "daughter", "XY": "son"}
    return f"Congratulations! You\'re going to have a {gender[sperm]}."


chromosome_check = lambda sperm: "Congratulations! You're going to have a %s." % {'XX':'daughter'}.get(sperm, 'son')

chromosome_check = lambda sperm: "Congratulations! You're going to have a son." if sperm == 'XY' else "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    return 'Congratulations! You\'re going to have a daughter.' if "XX" in sperm else 'Congratulations! You\'re going to have a son.'

def chromosome_check(sperm):
    message = 'Congratulations! You\'re going to have a'
    return f'{message} son.' if 'Y' in sperm else f'{message} daughter.'

def chromosome_check(sperm):
    a = sperm.upper()
    if a == 'XY':
       return 'Congratulations! You\'re going to have a son.'
    else:
       return 'Congratulations! You\'re going to have a daughter.'

chromosome_check = lambda s: f"Congratulations! You're going to have a {'son' if s[-1] == 'Y' else 'daughter'}."

def chromosome_check(sperm):
    if "XY" in sperm:
        return "Congratulations! You're going to have a son."
    elif "XX" in sperm:
        return "Congratulations! You're going to have a daughter."

def chromosome_check(sperm):
    return "Congratulations! You're going to have a {}.".format(('daughter', 'son')['Y' in sperm])

chromosome_check=lambda x:f"Congratulations! You\'re going to have a {'son' if 'Y' in x else 'daughter'}."

def chromosome_check(sperm):
    gender = {"XY": 'son', "XX":'daughter'}
    return 'Congratulations! You\'re going to have a {}.'.format(gender[sperm])
            
            


def chromosome_check(sperm):
    #Your code here
    return 'Congratulations! You\'re going to have a %s.' % ({'XX':'daughter', 'XY':'son', 'YX': 'son'}[sperm])

def chromosome_check(sperm):
    return f"Congratulations! You're going to have a {('daughter', 'son')['Y' in sperm]}."

chromosome_check = lambda sperm: "Congratulations! You're going to have a {0}.".format('son' if sperm[1] == 'Y' else 'daughter')

chromosome_check=lambda x: "Congratulations! You\'re going to have a son." if x=='XY' else "Congratulations! You\'re going to have a daughter."

def chromosome_check(sperm):
    x=0
    y=0
    for i in sperm:
           if i=="X":
                 x+=1
           else:
               y+=1
    if x==1 and y==1:
          a='''Congratulations! You\'re going to have a son.'''
          return a
    else:
          a='''Congratulations! You\'re going to have a daughter.'''
          return a

def chromosome_check(sperm):
    #Your code here
    if sperm == 'XX':
        return  'Congratulations! You\'re going to have a daughter.'
    elif sperm == 'XY':
        return 'Congratulations! You\'re going to have a son.'
    else:
        return 'stuff'


def chromosome_check(sperm):
    #Your code here
    a = "Congratulations! You're going to have a "
    if 'Y' in sperm:
        b= 'son.'
    else:
        b='daughter.'
    return f"{a}{b}"

def chromosome_check(s):
    m = 'Congratulations! You\'re going to have a {}.'
    return m.format('son') if s[-1] == 'Y' else m.format('daughter')

def chromosome_check(sperm):
    return f"Congratulations! You're going to have a {['daughter', 'son']['Y' in sperm]}."

def chromosome_check(sperm):
    if sperm[0:1] == sperm[1:]:
        return 'Congratulations! You\'re going to have a daughter.'
    else:
        return 'Congratulations! You\'re going to have a son.'