Skip to content

Instantly share code, notes, and snippets.

@KaratekHD
Created February 21, 2021 12:48
Show Gist options
  • Save KaratekHD/ee7e6defef77439e4c482cda16cabce7 to your computer and use it in GitHub Desktop.
Save KaratekHD/ee7e6defef77439e4c482cda16cabce7 to your computer and use it in GitHub Desktop.
Bio Hausaufgabe KW7 2021
from matplotlib import pyplot as plt
import seaborn as sns
# BioToolKW7 - Copyright (C) 2021 KaratekHD
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if __name__ == '__main__':
bakterien = []
x = 1
# Teilungen berrechnen
for i in range(0, 25):
if i == 0:
bakterien.append(1)
print(f"Teilung {i} : {x}")
else:
bakterien.append(x*2)
x = x*2
print(f"Teilung {i} : {x}")
print("")
# Jede zweite Teilung aus der Liste entfernen, um nur 12 Einträge zu haben
del bakterien[1::2]
# Liste ausgeben
print(bakterien)
print("")
# Bakterien pro Stunde ausgeben
i = 0
for element in bakterien:
print(f"Stunde {i}: {element}")
i = i + 1
# Diagram zeichnen
sns.set_style("whitegrid")
blue, = sns.color_palette("muted", 1)
x = [0, 1, 2, 3, 4, 5, 6]
y = bakterien[:7]
plt.plot(x, y, color=blue, lw=2)
plt.fill_between(x, 0, y, alpha=.3)
plt.ylabel("Anzahl der Bakterien")
plt.xlabel("Vergangene Zeit in h")
plt.title("Vermehrung von Bakterien bei einer Teilung je 30 Minuten")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment