Question: Using putty!!!! This homework is just a small code puzzle to exercise the concepts we've learned thus far: int s, float s, strings, and indexing

Using putty!!!!
This homework is just a small code "puzzle to exercise the concepts we've learned thus far: int s, float s, strings, and indexing with [] -syntax. Note: The use of Mypye "type annotations"/"type hints" for all of your variables is required; test your code beforehand with mypy Please place the files for this homework inside of a directory called $HOME/projects/hw2 1. Start by creating a script called hw2_1.py containing the following code: seq: str = "ACTGAGAGACTAC" Next, in this file, write some lines that 'split' this sequence approximately in half into variables called first_half and second_half, and prints them on the same line separated by a space. If the length of seq is an even number, the two halves should be the same length, but if it's an odd number, the first half should be one character shorter. Here's the line of code that you should include at the end: print(first_half + + second half) The printed output should be ACTGAG AGACTAC NOTE 1: The exact same code should work if we were to change the contents of the seq variable (but you may assume len(seq) will always be 2 or greater). For example, if I change the first line to seq: str = "ACTAGAGA" , the output should be ACTA GAGA without changing any other code. In fact, I plan to test that this works with some other sequence ;) NOTE 2: You should only use the concepts we've learned in class thus far, particularly the len() and int() functions, and [start_index:end_index] (aka "slice") syntax. NOTE 3: Do use type annotations in this code, and be sure that mypy hw2_1.py runs without reporting any errors. I will be doing the same as part of the grading process. 2. Create a hw2_2.py, which is exactly the same as hw2_1.py but with all of the type annotations removed. Notice what happens if you run /local/cluster/bin/python3.5 hw2_1.py (an older version of the python3 interpreter), vs /local/cluster/bin/python3.7 hw2_1.py (a newer version), as well as /local/cluster/bin/python3.5 hw2_2.py and /local/cluster/bin/python3.7 hw2_2.py . Try to 2. Create a hw2_2.py, which is exactly the same as hw2_1.py but with all of the type annotations removed. Notice what happens if you run /local/cluster/bin/python3.5 hw2_1.py (an older version of the python3 interpreter), vs /local/cluster/bin/python3.7 hw2_1.py (a newer version), as well as /local/cluster/bin/python3.5 hw2_2.py and /local/cluster/bin/python3.7 hw2_2.py. Try to figure out which version of python is run by default if we just say python3 by running python3 --version on the command-line. Make a note of your findings in a file called: hw2_3.txt a 3. Do some 'typing' exploration on your own. What happens if you run print(int(true)) ? What about print(int(False)) ? What about print(int(None)) ? We also talked about the int(), float(), and str() conversion functions-explore on your own what happens to various types when converting between them. What about other data types, e.g., Lists, that may have been covered? Do you always get the type that's asked for? Place your observations in a file called: hw2_4.txt (The goal of this question is to "explore" how Python handles various scenarios and "edge cases")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
