Your instructor may assign one or more of the following problems. Don’t feel that you must do all the problems; for the homeworks, you are only required to do those that are explicitly assigned via Moodle.
DNA_mutation.py that prompts the user for a
string, and a pattern that is present in both the forward and reverse
directions of the string. Your program should locate the leftmost
occurrence of the pattern, and the next subsequent occurrence of the
inverted pattern. The output should be a mutated string where the
substring between the pattern and inverted pattern identified is
reversed. A few examples follow: =================================================================== Enter a sequence of characters: cgattgaacattaagtccaatt Enter the pattern: tgaa Mutated sequence: cgattgaattacaagtccaatt =================================================================== Enter a sequence of characters: hiPattAbCttaPbye Enter the pattern: Patt Mutated sequence: hiPattCbAttaPbye =================================================================== Enter a sequence of characters: 123456ablewasIereIsawelba654654321 Enter the pattern: 456 Mutated sequence: 123456ablewasIereIsawelba654654321 ===================================================================Hints:
original in Python you
can use: reverse = original[::-1]find
helpful (and you are allowed to use it!)
Write a turtle graphics program called triangle.py that reads three sets of x-y
coordinates from the user, represents them as three tuples
where each tuple represents a point (as you did in the lab
exercise).
With this data structure in place, do the following.
As an example, see the two sample runs on the right. Note that the set of points is printed as a list of tuples, as specified above.
To simplify the problem, your program may assume that the first two points are on the x axis. Be sure to test various examples that satisfy this criterion.
Write a program called shuffler.py to thoroughly shuffle a list of values, by repeatedly 1) removing
a value from a random place in the list and then 2) inserting that value back into
the list at a random location.
Have your code first create a list containing 26 strings: 'a', 'b', 'c', etc. Your
code does not have to do this programmatically. You should just simply
type the list in by hand. E.g., letters = ['a', 'b', typetheresthere...].
Ask the user how many times to shuffle values in the list. Store the result in an
integer variable numTimes.
Next, your code to remove and reinsert the value as many times as the user wants.
Finally, print out the shuffled list.
Hints:
import random at the top of your file, and then use
rand_loc = random.randint(0, len(theList) - 1) to get a
random index into the list theList.
for loop, like so:
for iter in range(numTimes):
your code here, indented
4 spaces for each line.
That code will execute the indented lines numTimes times.random.shuffle(), which does everything
this assignment is asking, in one line.We will grade this assignment according to the following criteria:
homework03