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..c267ea4 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,33 @@ -#YOUR CODE FOR EX_0 ADVANCED HERE \ No newline at end of file +def analyze_dna_sequence(dna_sequence): + # Initialize counts + a_count = dna_sequence.count('A') + c_count = dna_sequence.count('C') + g_count = dna_sequence.count('G') + t_count = dna_sequence.count('T') + + # Calculate total length and GC content + sequence_length = len(dna_sequence) + gc_content = (g_count + c_count) / sequence_length * 100 if sequence_length > 0 else 0 + + # Display results + print(f"Sequence Length: {sequence_length}") + print(f"Adenine (A) Count: {a_count}") + print(f"Cytosine (C) Count: {c_count}") + print(f"Guanine (G) Count: {g_count}") + print(f"Thymine (T) Count: {t_count}") + print(f"GC Content: {gc_content:.2f}%") + + +def main(): + # Prompt user for input + dna_sequence = input("Enter a DNA sequence (A, C, G, T): ").upper() + + # Validate the input + if all(base in 'ACGT' for base in dna_sequence): + analyze_dna_sequence(dna_sequence) + else: + print("Error: Invalid DNA sequence. Please use only A, C, G, and T.") + + +if __name__ == "__main__": + main() \ No newline at end of file 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..8a50fc3 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 May Hadded, I am 21 years old, I'm a student at CARe. I did my bachelor at the university of Greenwich. I aspire to work for a big skin care firm, discovering new solutions can be done through analysis done with programming tools.") -print("\n"+"TYPE YOUR RESPONSE TO PROMPT 2 HERE") \ No newline at end of file +print("\n"+"The last time I was somewhere without a computer was in a mountain in Turkey.") \ 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..dfd73c8 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,29 @@ Copy and paste output of ex_0_beginner_runfile.py below: +/usr/local/bin/python3.13 /Users/mayhadded/PycharmProjects/CARe_Python_Class_2024/week_0/ex_0_beginner/ex_0_beginner_runfile.py +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 May Hadded, I am 21 years old, I'm a student at CARe. I did my bachelor at the university of Greenwich. I aspire to work for a big skin care firm, discovering new solutions can be done through analysis done with programming tools. + +The last time I was somewhere without a computer was in a mountain in Turkey. + +Process finished with exit code 0 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..8928304 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,28 @@ -#YOUR CODE FOR EX_0 INTERMEDIATE HERE \ No newline at end of file +import math + +def calculate_growth_rate(): + try: + # Prompt the user to input the initial count, final count, and time + initial_count = float(input("Enter the initial cell count: ")) + final_count = float(input("Enter the final cell count: ")) + time = float(input("Enter the time elapsed (in hours): ")) + + # Validate inputs + if initial_count <= 0 or final_count <= 0: + print("Cell counts must be positive numbers.") + return + if time <= 0: + print("Time must be a positive number.") + return + + # Calculate the growth rate using the formula + growth_rate = (math.log(final_count) - math.log(initial_count)) / time + + # Display the growth rate + print(f"The growth rate of the microbial culture is: {growth_rate:.4f} per hour") + + except ValueError: + print("Invalid input. Please enter numerical values for cell counts and time.") + +# Call the function to run the program +calculate_growth_rate() \ No newline at end of file