Python Crash Course


The Python Crash Course is a free course that teaches the basics of python programming. Topics covered in the course include variables, conditionals, loops, functions, classes, and tips for debugging. Each lesson is described below and the video playlist for this course can be accessed on YouTube.

Lesson 1 Resources

This lesson introduces the following python concepts!

  • What is programming?
  • What is a programming language?
  • What is python?
  • How to install python
  • Text Editors and IDEs for coding in python

Refer to the following resources for written tutorials!

Lesson 2 Resources

This lesson introduces the following python concepts!

  • Input
  • Output
  • Comments

Refer to the following resources for written tutorials!

Homework 1

Write a program that prints hello world to the screen
Write a program that asks the user to input their name, age, and favorite food.
Write a program that asks the user for their name and prints it back out to the user.
Read information from the input.txt file. Display this information back out to the user.

Refer to the following for written homework solutions.

Lesson 3 Resources

This lesson introduces the following different types of variables in python!

Basic Variable TypesData Structure Variable Types
intstring
floatlist
booleantuple
chardictionary

Refer to the following resources for written tutorials!

Homework 2

Ask the user for a number. Multiply the number by 10 and print it back out to the user
Ask the user for two numbers. Divide the first number by the second number and print out the result.
Ask the user for their name, age, and favorite food. Print out 1 message to the user with all of this information.
Ask the user for their year of birth. Calculate how old they are based on todays year. Return this result back out to the user
Ask the user for three numbers and make a list out of these numbers. Print out the resulting list.
Access the first and last element in a list and print it out to the screen. Make sure to test your code on lists of various sizes! Hint: len(your list variable) returns the number of elements in the list
Create a 10 element long list. Ask the user for a number between 1 and 10 and another number. Insert the second number into your created list at the position of the first number.
Example:
User Input: 3, 50
samplestartinglist = [1,2,3,4,5,8,6,9,10]
Program Output: [1,2,3,50,5,8,6,9,10]

Lesson 4 Resources

This lesson introduces the following python concepts!

  • Conditional Statements (if/else/elif)

Refer to the following resources for written tutorials!

Homework 3

Write a program that asks a user for their birthday (month day and year). Calculate how old the user is. Determine whether the user is an adult (18 years and older). Return your results to your user.
Write a program that creates three random numbers. Determine which number is the greatest and which number is the least. HINT: The following code snippet creates a random number.# Import the random module import random # Use the random module to get a random number between 0 to 100. random.randint(0,100)
Write a program that presents 5 products with associated prices to the user. Have the user pick 2 products that they want to buy. Calculate the total cost for these products. Print out to the user the total cost of purchase.
BONUS QUESTION: The following three sequences come from the KRAS gene (https://www.ncbi.nlm.nih.gov/nuccore/NM_001369786.1?report=fasta).GGCGGC TTTGCCATAAATAATACTAAATCATTT GAAACAAATTAATGAAGCTTTTGAATCATCCCTATTCTGTGTTTTATCTAGTCACATAAATGGATTAATTWrite a program that determine if the first three base pairs are equal to the last three base pairs for each sequence. Your code should be able to work on all test cases without modification.

BONUS QUESTION: Using the following mRNA codon chart (https://www.shsu.edu/academics/agricultural-sciences-and-engineering-technology/documents/mRNAcodonchart.pdf), write a program that coverts a three base pair sequence to the corresponding an amino acid.

Challenge: Can you do this without conditional statements?

This lesson introduces the following python concepts!

  • While Loops
  • For Loops

Refer to the following resources for written tutorials!

Homework 4

Write a program that prints out a message until the user enters q.
Write a program that prints out "I like cheese" backwards. Challenge: Can you do this entire program in less than 3 lines of code?

Write a program that presents the user with 10 items and associated prices. Ask the user to pick 5 items. Calculate the total price of the items.

HINT: Using loops and some of the data structure type variables we talked about in previous lessons will make this program much easier! Be sure to check out the documentation for the data structures you use! There are some nifty functions that are super useful!

Write a program that
  • reads in the KRAS DNA sequence (found here)
  • transcribes the DNA to mRNA
  • translates the mRNA sequence into a peptide chain

Do this for all three reading frames. Assume that no processing of the mRNA occurs. Save your results to 3 files.

HINT: The link provided links to the KRAS gene in the FAFSA file format on the NCBI website. Please note that the first line in FAFSA format contains a description of the sequence. For simplicity sake, delete this line in your file. Additionally, use this mRNA codon chart (https://www.shsu.edu/academics/agricultural-sciences-and-engineering-technology/documents/mRNAcodonchart.pdf) to translate the DNA. Finally, the following code segment will remove new lines in a string.

striped_str = mystring.replace("\n","")

Lesson 6 Resources

This lesson introduces the following python concepts!

  • functions

Refer to the following resources for written tutorials!

Homework 5

Write a program using functions that takes in two numbers, multiplies them together, and prints the result back out to the user."

Write a program that uses functions to calculate any given number in the Fibonacci sequence.

Is there a way to optimize this using a data structure that we talked about previously?

Write a function that takes in two lists. The first list contains the value of a card (2 through 10 and then Jack, Queen, King, Ace). The second list contains the suit of the card. Calculate the total value of the cards passed in. Face cards are worth 10 points each and Aces are worth 1 point. Return the results back out to where the function was called.

Lesson 7 Resources

This lesson introduces the following python concepts!

  • Modules
  • Packages

Refer to the following resources for written tutorials!

Homework 6

Write a python program that generates 10 random numbers and prints them to the screen

Write a python program that prints the name of all of the files in the current folder.

HINT: You will have to google to find an appropriate built in module

BONUS: Use the Pydealer package to simulate the game Yousef

Lesson 8 Resources

Video lecture coming soon! Be sure to subscribe to our YouTube channel to get the latest news on video releases.

This lesson introduces the following python concepts!

  • Classes

Refer to the following resources for written tutorials!

Homework 7

Create a python program that simulates the game of Yousef. Instructions as how to play the game can be found on this website

HW video coming soon! Be sure to subscribe to our YouTube channel to get the latest news on video releases.