alberthrocks

Gene Probability Python Code, shorter

Mar 21st, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. from random import *
  2. genotype = [0,0]
  3. homoDom,heteroDom,homoRec,dom,rec=0,0,0,0,0
  4. print "Genotype\t| Genotype name\t\t| Phenotype"
  5. print "====================================================="
  6. for x in range(0,100):
  7.     genotype[0]=int(randrange(0,100)/50)
  8.     genotype[1]=int(randrange(0,100)/50)
  9.     if genotype[0] == 1:
  10.             if genotype[1] == 1:
  11.                 print "RR \t\t| homozygous dominant\t| normal skin"
  12.                 homoDom+=1
  13.             else:
  14.                 print "Rr \t\t| heterozygous dominant\t| normal skin"
  15.                 heteroDom+=1
  16.     else:
  17.         if genotype[1] == 1:
  18.             print "rR\t\t| heterozygous dominant\t| normal skin"
  19.             heteroDom+=1
  20.         else:
  21.             print "rr\t\t| homozygous recessive\t| albino"
  22.             homoRec+=1
  23. print "Statistics:"
  24. print "RR: "+str(homoDom)+"/100 Rr or rR: "+str(heteroDom)+"/100 rr: "+str(homoRec)+"/100."
  25. rec=homoRec
  26. dom=homoDom+heteroDom
  27. print str(dom)+"/100 were dominant. "+str(rec)+"/100 were recessive."
  28. a=raw_input("Press ENTER to exit... ")
Advertisement
Add Comment
Please, Sign In to add comment