From bc1f9d541a740afb22a4d0f35621372088241df4 Mon Sep 17 00:00:00 2001 From: JulienPy Date: Thu, 21 Sep 2023 15:36:53 +0200 Subject: [PATCH 1/5] Prompt=> responses --- week_0/ex_0_beginner/ex_0_beginner_runfile.py | 4 +-- week_0/ex_0_beginner/ex_0_beginner_submit.txt | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/week_0/ex_0_beginner/ex_0_beginner_runfile.py b/week_0/ex_0_beginner/ex_0_beginner_runfile.py index b3db532..f899941 100644 --- a/week_0/ex_0_beginner/ex_0_beginner_runfile.py +++ b/week_0/ex_0_beginner/ex_0_beginner_runfile.py @@ -1,5 +1,5 @@ import this -print("\n"+"TYPE YOUR RESPONSE TO PROMPT 1 HERE") +print("\n"+"My name is Julien, I am in M2 CARe and I am passionate about cancer research. Programming is getting really important in that field due to the amount of data that need analysis or prediction.") -print("\n"+"TYPE YOUR RESPONSE TO PROMPT 2 HERE") \ No newline at end of file +print("\n"+"I don't recall any.") \ No newline at end of file diff --git a/week_0/ex_0_beginner/ex_0_beginner_submit.txt b/week_0/ex_0_beginner/ex_0_beginner_submit.txt index b4d44a7..59eb835 100644 --- a/week_0/ex_0_beginner/ex_0_beginner_submit.txt +++ b/week_0/ex_0_beginner/ex_0_beginner_submit.txt @@ -1 +1,28 @@ Copy and paste output of ex_0_beginner_runfile.py below: +The Zen of Python, by Tim Peters + +Beautiful is better than ugly. +Explicit is better than implicit. +Simple is better than complex. +Complex is better than complicated. +Flat is better than nested. +Sparse is better than dense. +Readability counts. +Special cases aren't special enough to break the rules. +Although practicality beats purity. +Errors should never pass silently. +Unless explicitly silenced. +In the face of ambiguity, refuse the temptation to guess. +There should be one-- and preferably only one --obvious way to do it. +Although that way may not be obvious at first unless you're Dutch. +Now is better than never. +Although never is often better than *right* now. +If the implementation is hard to explain, it's a bad idea. +If the implementation is easy to explain, it may be a good idea. +Namespaces are one honking great idea -- let's do more of those! + +My name is Julien, I am in M2 CARe and I am passionate about cancer research. Programming is getting really important in that field due to the amount of data that need analysis or prediction. + +I don't recall any. + +Process finished with exit code 0 From e902db94462a6f2be6b9e99126c1afb2659465ae Mon Sep 17 00:00:00 2001 From: JulienPy Date: Wed, 4 Oct 2023 20:44:22 +0200 Subject: [PATCH 2/5] ex_0_intermediate --- .../ex_0_intermediate_runfile.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/week_0/ex_0_intermediate/ex_0_intermediate_runfile.py b/week_0/ex_0_intermediate/ex_0_intermediate_runfile.py index 919a326..04cbacb 100644 --- a/week_0/ex_0_intermediate/ex_0_intermediate_runfile.py +++ b/week_0/ex_0_intermediate/ex_0_intermediate_runfile.py @@ -1 +1,18 @@ -#YOUR CODE FOR EX_0 INTERMEDIATE HERE \ No newline at end of file +import math + +initial_count = input("Enter the initial cell count: ") +final_count = input("Enter the final cell count: ") +time = input("Enter the time elapsed: ") + +try: + initial_count = int(initial_count) + final_count = int(final_count) + time = float(time) + if initial_count <= 0 or final_count <= 0 or time <= 0: + print("You must enter a positive number") + + else: + growth_rate = (math.log(final_count) - math.log(initial_count)) / time + print(growth_rate) +except ValueError: + print("Invalid input, please enter integer values for initial_count and final_count") From d61e9a3985f540b8f53d03c0a5074efac56d3f2f Mon Sep 17 00:00:00 2001 From: JulienPy Date: Thu, 5 Oct 2023 21:47:16 +0200 Subject: [PATCH 3/5] ex_0_advanced --- week_0/ex_0_advanced/ex_0_advanced_runfile.py | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/week_0/ex_0_advanced/ex_0_advanced_runfile.py b/week_0/ex_0_advanced/ex_0_advanced_runfile.py index ca4c2ba..db44304 100644 --- a/week_0/ex_0_advanced/ex_0_advanced_runfile.py +++ b/week_0/ex_0_advanced/ex_0_advanced_runfile.py @@ -1 +1,27 @@ -#YOUR CODE FOR EX_0 ADVANCED HERE \ No newline at end of file + +#GTCGATAACTAGCTAACGGCT + +def DNA_sequence_analysis(seq): + + count_A = seq.count("A") + count_C = seq.count("C") + count_G = seq.count("G") + count_T = seq.count("T") + GC_tot = count_G + count_C + GC_content = (GC_tot/len(seq)) * 100 + print("Adenine count: ",count_A) + print("Cytosine count: ",count_C) + print("Guanine count: ",count_G) + print("Thymine count: ",count_T) + print("GC content is: ", GC_content) + + +seq = str(input("Enter your DNA sequence: ")) +if any(x not in ["A","C","G","T"] for x in seq): + print("Please enter a DNA sequence") +else: + length = len(seq) + + print("DNA sequence length: ",length) + + print(DNA_sequence_analysis(seq)) \ No newline at end of file From e1fdb2747e6cb1956946f3a3f902cb25578f4e03 Mon Sep 17 00:00:00 2001 From: JulienPy Date: Thu, 12 Oct 2023 05:08:55 +0200 Subject: [PATCH 4/5] ex_1_beginner --- week_1/ex_1_beginner/ex_1_beginner_submit.txt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/week_1/ex_1_beginner/ex_1_beginner_submit.txt b/week_1/ex_1_beginner/ex_1_beginner_submit.txt index 5dfc523..40e5f86 100644 --- a/week_1/ex_1_beginner/ex_1_beginner_submit.txt +++ b/week_1/ex_1_beginner/ex_1_beginner_submit.txt @@ -1 +1,25 @@ Copy and paste output of ex_1_beginner_runfile.py below: + +#First we define a function "stats" that will calculate the average population count and print the max and min population count + +def stats(population_counts): + total_population = sum(population_counts) + average_population = total_population/ len(population_counts) + max_population = max(population_counts) + min_population = min(population_counts) + print("Average population count: ",average_population) + print("Maximum population count: ",max_population) + print("Minimum population count: ",min_population) + +#we then enter our population count data and apply to it the function that we defined above. + +population_counts = [100, 200, 150, 300, 50] +print(stats(population_counts)) + +#we create a loop using the function enumerate, this function will give the value (called here "population count") aswell as the index (called here "x") corresponding to that value. We setup the starting index as 1 (as day 1). +# If the population count is above 200, the index will be printed (here day 4) and the loop continue. + +print("Days when the population exceeds 200: ") +for x,population_count in enumerate(population_counts, start=1): + if population_count>200: + print("Day ", x) From 83d259cbe2b0fa3b6c6df6fb529a60b4e05379d4 Mon Sep 17 00:00:00 2001 From: JulienPy Date: Fri, 13 Oct 2023 08:11:36 +0200 Subject: [PATCH 5/5] ex_1_intermediate --- .../ex_1_intermediate_submit.txt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/week_1/ex_1_intermediate/ex_1_intermediate_submit.txt b/week_1/ex_1_intermediate/ex_1_intermediate_submit.txt index 66cbfd4..a83391a 100644 --- a/week_1/ex_1_intermediate/ex_1_intermediate_submit.txt +++ b/week_1/ex_1_intermediate/ex_1_intermediate_submit.txt @@ -1 +1,34 @@ Copy and paste output of ex_1_intermediate_runfile.py below: + +#first we define a dictionary of species with counts +microbial_species = {"Bacteria": 20, "Archaea": 15, "Fungi": 10} + +#create a function that add up the species entries counts. Or define a new count starting at 1 if the species is new. Species dictionary being at first microbial_species +def add_species_to_dictionary(species_dictionary, new_species): + if new_species in species_dictionary: + species_dictionary[new_species] +=1 + else: + species_dictionary[new_species] = 1 + +#loop asking user to enter a species or end the loop. The species entered will add to dictionary names and counts. +# I thought this step and the one above made more sense added first into the code as the user will first enter his species and then see the result. +while True: + new_species=input ("Enter a species name or 'end' if you want to stop adding species: ") + if new_species== 'end': + break + add_species_to_dictionary(microbial_species,new_species) + +#printing species' names and samples' count from the dictionary +for species, count in microbial_species.items(): + print(f"{species}: {count} samples") + +#adding up all samples counts +total_samples= sum(microbial_species.values()) +print("Total number of samples from all species combined: ", total_samples) + +#asking to print species from dictionary with count over 15 +samples_over_15=[species for species, count in microbial_species.items() if count >15 ] +print ("microbial species with sample counts greater than 15: ", samples_over_15) + +#printing the dictionary with samples count +print("Microbial species dictionary: ",microbial_species) \ No newline at end of file