Created
May 24, 2016 19:12
-
-
Save marko-knoebl/ffc3b8a8dab2d3ae336d06e7e29a43c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the dna.txt file needs to be in the same folder | |
dna = open('dna.txt').read() | |
print 'The Profile of the DNA is:' | |
#Hair color | |
if 'CCAGCAATCGC' in dna: | |
hair_color = 'black' | |
elif 'GCCAGTGCCG' in dna: | |
hair_color = 'brown' | |
elif 'TTAGCTATCGC' in dna: | |
hair_color = 'carrot' | |
print 'Hair color: ' + hair_color | |
#Facial shape | |
if 'GCCACGG' in dna: | |
facial_shape = 'square' | |
elif 'ACCACAA' in dna: | |
facial_shape = 'round' | |
elif 'AGGCCTCA' in dna: | |
facial_shape = 'oval' | |
print 'Facial shape: ' + facial_shape | |
#Eye color | |
if 'TTGTGGTGGC' in dna: | |
eye_color = 'blue' | |
elif 'GGGAGGTGGC' in dna: | |
eye_color = 'green' | |
elif 'AAGTAGTGAC' in dna: | |
eye_color = 'brown' | |
print 'Eye color: ' + eye_color | |
#Gender | |
if 'TGAAGGACCTTC' in dna: | |
gender = 'female' | |
elif 'TGCAGGAACTTC' in dna: | |
gender = 'male' | |
print 'Gender: ' + gender | |
#Race | |
if 'AAAACCTCA' in dna: | |
race = 'white' | |
elif 'CGACTACAG' in dna: | |
race = 'black' | |
elif 'CGCGGGCCG' in dna: | |
race = 'asian' | |
print 'Race: ' + race | |
# if a line gets too long (usually more than 80 characters) we can break it up | |
# into multiple lines, but we need to enclose the expression in round brackets: (...) | |
if (hair_color == 'carrot' and facial_shape == 'round' and eye_color == 'brown' | |
and gender == 'male' and race == 'white'): | |
print "It's Ziga" | |
if (hair_color == 'black' and facial_shape == 'oval' and eye_color == 'blue' | |
and gender == 'male' and race == 'white'): | |
print "It's Matej" | |
elif (hair_color == 'brown' and facial_shape == 'square' and eye_color == 'green' | |
and gender == 'male' and race == 'white'): | |
print "It's Miha" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment