Day 2 - Python Review Workshop
Wednesday 8B | Room 57
9/17/2025
Quick Review
Operators
Data Types
Loops
Learn:
input
how to comment
Kahoot Time!!
Get your computers out :D
Downloading Python:
Online python environment:
python.org/downloads/
online-python.com
Problem #1
The Problem
Write a Python program that takes a DNA sequence and generates its reverse complement.
Input
A string variable named dna_sequence. For example: dna_sequence = "AGTC"
Expected Output
A string representing the reverse complement of the input. For "AGTC", the output should be "GACT".
Biological Context - DNA has two complementary strands. One strand runs in the 5' to 3' direction, and the other runs in the 3' to 5' direction.
Problem #1 - Hints/Structure
Create an empty string to store the reverse complement.
Use a for loop to iterate through the input dna_sequence in reverse order.
Inside the loop, use an if-elif-else statement to find the complement of each base:
Print the final reverse complement string.
Problem #2
The Problem
Write a Python program that counts the occurrences of a few specific amino acids in a protein sequence.
Input
A string variable named protein_sequence. For example: protein_sequence = "MVLSPADKTN". You will also be looking for the counts of the amino acids 'M', 'V', and 'A'.
Expected Output
A list of integers representing the counts of each specified amino acid. For "MVLSPADKTN", the output should be [1, 1, 1] for 'M', 'V', and 'A' respectively.
Problem #2 - Hints/Structure
Create a list with three elements, all initialized to zero, to store the counts for 'M', 'V', and 'A'.
Use a for loop to iterate through each character in the protein_sequence string.
Inside the loop, use if-elif-else statements to check for 'M', 'V', and 'A'.
Print the final list of counts.
Problem #3
The Problem
Write a Python program that finds all the starting positions of a specific short DNA sequence (a "restriction site") within a larger DNA sequence.
Input
Two string variables: dna_sequence (the larger sequence) and restriction_site (the shorter sequence).
Example: dna_sequence = "GAATTCGGATCC", restriction_site = "GAATTC"
Expected Output
A list of integers representing the starting indices of the restriction site within the DNA sequence. For the example above, the output should be [0]. If restriction_site = "GGATCC", the output should be [6].
Problem #3 - Hints/Structure
Create an empty list to store the indices.
Determine the lengths of both the dna_sequence and the restriction_site.
Use a for loop with the range() function to iterate through the dna_sequence from the beginning to the point where a match is still possible.
Inside the loop, use list slicing to extract a segment of the dna_sequence of the same length as the restriction_site.
Use an if statement and the == operator to check if this segment is equal to the restriction_site.
If there's a match, add the current index to your list of indices.
Print the final list of indices.