-
Notifications
You must be signed in to change notification settings - Fork 35
assignment Ilias Simon #24
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: master
Are you sure you want to change the base?
Changes from all commits
780c8c0
9c92ee8
39aec37
4382b9c
b3bbaaa
0254093
61672c9
b11ddec
8c09b4d
f0adf6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,29 @@ | ||
| #YOUR CODE FOR EX_0 ADVANCED HERE | ||
| while True: | ||
| sequence = str(input("enter your DNA sequence: ")) | ||
| sequence = sequence.upper() | ||
| valid = True | ||
| for i in sequence: | ||
| if i not in "ATGC": | ||
| print("please enter a valid DNA sequence (ATGC)") | ||
| valid = False | ||
| break | ||
| if valid: | ||
| break | ||
| sequence_length = int(len(sequence)) | ||
| nA = sequence.count("A") | ||
| nT = sequence.count("T") | ||
| nG = sequence.count("G") | ||
| nC = sequence.count("C") | ||
| GC_content = nG + nC | ||
| GC = ((GC_content)/sequence_length) | ||
| print("sequence length =" +str(sequence_length)) | ||
| print("number of A: " +str(nA)) | ||
| print("number of T: " +str(nT)) | ||
| print("number of G: " +str(nG)) | ||
| print("number of C: " +str(nC)) | ||
| print("number of GC= " +str(GC_content), end="") | ||
| print(" with a proportion of" + str(GC)) | ||
| if GC > 0.5: | ||
| print(" Your sequence is rich in GC") | ||
| else: | ||
| print(" Your sequence is poor in GC") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import this | ||
|
|
||
| print("\n"+"TYPE YOUR RESPONSE TO PROMPT 1 HERE") | ||
|
|
||
| print("\n"+"TYPE YOUR RESPONSE TO PROMPT 2 HERE") | ||
| print("1- Hi, my name is ilias SIMON, i'm a M2 student following the CARe graduate program.") | ||
| print("I wish to persue my career in biology with a phd and i found out how much developing", end="") | ||
| print(" and coding was important for several life-changing applications in this field.") | ||
| print("2- never i guess x)") |
|
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. Please be sure that the beginner_runfile was able to be run. The "import this" line should produce a poem before the answer to your prompts is output. This is for me to ensure that your PyCharm is able to interpret Python code as it should. Please copy and paste the entire output from the runfile appearing on the console into the submit.txt file and resubmit. Thank you in advance. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| Copy and paste output of ex_0_beginner_runfile.py below: | ||
| 1- Hi, my name is ilias SIMON, i'm a M2 student following the CARe graduate program. | ||
| I wish to persue my career in biology with a phd and i found out how much developing and coding was important for several life-changing applications in this field. | ||
| 2- never i guess x) |
|
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. Great effort on this part. I do, however, have some recommendations. There is a simpler way to determine if a variable that the user inputs is an int variable type (think first lesson on the first day), rather than iterating through a list of ALL possible integer values. Additionally, once the user's integer input has been validated, there are two other logical conditions that must be satisfied, which we will talk about next class, but feel free to implement in the meantime. I will provide a final grade once this code is both 1) simplified and 2) takes into account the remaining numerical conditions. Best of luck, and feel free to ask any questions using this platform.
Author
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. Thank you very much for this surprinsingly quick correction,
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. Nicely done with testing if the input is numerical in a more straightforward manner. Now the only thing left to do is ensure that the numerical input is both positive (as negative log will result in an error) and that the end number of cells is always greater than the beginning, as this is a measurement of exponential growth and not decay.
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. Excellently done. Score: 1.5/1.5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,19 @@ | ||
| #YOUR CODE FOR EX_0 INTERMEDIATE HERE | ||
| print("this program will calculate the Microbial Growth Rate based on your parameters, follow the instructions.") | ||
| while True : | ||
| start= input("Enter the number of cells at the beginning: ") | ||
| end= input("Enter the number of cells at the end: ") | ||
| time= input("enter the time between start and end: ") | ||
| valid = True | ||
| lst = [start,end,time] | ||
| for i in lst: | ||
| if i.isdigit(): | ||
| valid= True | ||
| else: | ||
| valid= False | ||
| if valid: | ||
| break | ||
| else: | ||
| print("please enter a numerical value") | ||
| import math | ||
| Growth_rate= (math.log(int(end))-math.log(int(start)))/int(time) | ||
| print("This population of cells have a GR of " + str(Growth_rate)) |
|
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. For this, you will need to load the lines of each file into a dictionary with the reference numbers as keys, iterate through the dictionaries, and determine if the entry is identical or not, and if not provide a list of the differences in the strings. You have a good start here with reading in the files. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,16 @@ | ||
| #YOUR CODE FOR EX_1 ADVANCED HERE | ||
| #YOUR CODE FOR EX_1 ADVANCED HERE | ||
| def str_sup(file_name, str_suppressed): | ||
| with open(file_name,'r', encoding='utf-8') as file: | ||
| content= file.read() | ||
| content= content.replace(str_suppressed,'') | ||
| with open(file_name,'w', encoding='utf-8') as file: | ||
| file.write(content) | ||
| return f"string {str_suppressed} was removed from {file_name}" | ||
|
|
||
| file_name1= "references_1.txt" | ||
| file_name2= "references_2.txt" | ||
| str_space= " " | ||
| ref1= str_sup(file_name1, str_space) | ||
| ref2= str_sup(file_name2,str_space) | ||
| print(ref1) | ||
| print(ref2) |
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.
Good work on accomplishing the objectives. There is, however, a more efficient way to "count" the number of occurrences in a string rather than having to iterate through each character and increment counter variables. Please refer to the link below, and you should be able to condense around 20 lines of this into only 4, a good practice with code "refactoring".
https://stackoverflow.com/questions/1155617/count-the-number-of-occurrences-of-a-character-in-a-string
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.
Excellently done in incorporating "simple is better than complex", "flat is better than nested" into your code.
Score: 2/2