Question
with open(the.txt) as ecoli: from collections import defaultdict counts = defaultdict(int) for line in ecoli: if line.startswith(>): continue for char in line: if char in
with open("the.txt") as ecoli:
from collections import defaultdict
counts = defaultdict(int)
for line in ecoli:
if line.startswith(">"):
continue
for char in line:
if char in {"A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"}:
counts[char] += 1
total = float(sum(counts.values()))
for key,val in counts:
print ("{}: {}, ({:.1%})".format(key,val, val / total))
Can someone please expain to me how would you go about taking the results (below) and orgazing them in terms of percentage??? As in, I want the highest percetage on the top and lowest on the bottom.
THANKS
Results:
G: 95475 (7.4%) F: 50554 (3.9%) I: 77836 (6.0%) H: 29255 (2.3%) K: 57151 (4.4%)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started