-
Notifications
You must be signed in to change notification settings - Fork 16
Submission of beginner level #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0ba9a54
8d64d4e
84fb73b
15ddb22
34225e6
660faa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,33 @@ | ||
| #YOUR CODE FOR EX_0 ADVANCED HERE | ||
| 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() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") | ||
| print("\n"+"The last time I was somewhere without a computer was in a mountain in Turkey.") |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very well done here, May! You have set up both PyCharm and GitHub and connected the two with a push and pull request. Because "import" opened the "this" Python library, and the poem was output, that tells me that Python3 now works on your computer. It seems you're coding your way to a glowing career in skincare! From Greenwich to CARe, you're certainly not resting on your laurels. Aspiring to work for a big skincare firm? I bet you're itching to debug those pesky skin problems and compile some radiant solutions. Just remember, when you're deep in your programming, don't mistake the face cream for thermal paste! Speaking of unplugging, I hear you managed to escape the digital world on a Turkish mountain. Was that a quest for the ultimate natural exfoliant? Good work and best of luck with the next assignments. Score: 0.5/0.5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very eloquent implementation of this using function encapsulation and try/except ValueError to handle non numeric input. The only thing to do now is ensure that the "growth" rate has values higher for the final count than the initial count. It is also important that the numerical value should not be a float, since you cannot have a fraction of a cell. This edits should be simple enough given your excellent progress so far. Score: pending/1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,28 @@ | ||
| #YOUR CODE FOR EX_0 INTERMEDIATE HERE | ||
| 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. All tasks satisfied with shorthand if/else notation for variable assignment, as well as using the "in" conditional to test for ATCG.
Score: 2/2