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.";

Source: codewars | Difficulty: EASY
Tags: Fundamentals

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):
	return f"Congratulations! You're going to have a {('son' if sperm == 'XY' else 'daughter')}."


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(sperm):
	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 "Congratulations! You're going to have a {}.".format('daughter' if sperm == 'XX' else 'son')


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 {}.".format('son' if 'Y' in sperm 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):
	gender = 'son' if sperm[-1] == 'Y' else 'daughter'
	return f"Congratulations! You're going to have a {gender}."


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 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(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):
	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):
	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):
	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):
	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):
	return "Congratulations! You're going to have a {}.".format(['son', 'daughter'][sperm.count('X') - 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):
	msg = "Congratulations! You're going to have a "
	child = ('daughter.', 'son.')['Y' in sperm]
	return msg + child


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."


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."


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


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


chromosome_check = lambda sperm: "Congratulations! You're going to have a {0}.".format('son' if sperm[1] == 'Y' else '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(s):
	m = "Congratulations! You're going to have a {}."
	return m.format('son') if s[-1] == 'Y' else m.format('daughter')