Homework - LuiGarza/PythonPrep GitHub Wiki

Welcome

We offer this quick preparation list to help screen our candidates for the Full Stack Engineer Position. You may find this very easy or very challenging. We have hired people at different skill levels and we are committed to mentor those who join our team. You are not required to do these exercises or turn them in to anyone. We simply want to make sure that everyone who comes in for a technical skill test is prepared and doesn't have a difficult time.

If you are experienced feel free to skim or disregard these exercises I trust you know where you stand. For those in the apprenticeship or entry level position you may find this extremely useful.

We want you to succeed.


Basic skill refresher

You will be working with python so make sure you are able to run python on your computer. We use Linux and our terminal prompt intensely at Earthwave Technologies so make sure you are familiar with it. First off take a moment to visit https://opentechschool.github.io/python-beginners/en/getting_started.html

Make sure to look through https://www.python.org/ you can find python documentation and other useful information here.

Version control is huge and you should have a basic understanding of how it works and why. https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners

Once set up these commands are a must: git add, git commit, git push and git pull

Use google and any resources you wish to get through it all.

Please contact me with any questions may have if steps appear vague or confusing. Thanks!

Basics - Terminal, Files and Version control:

  1. Go to github.com and create an account. (This website)

  2. Create a free public project.

  3. Follow the instructions to create a new project and set it up so you can push from your computer to the repository. Call it dev-exercises.

  4. Create an executable Python File.

  5. Run this file. (Prove the file runs: Return a string like “Hello World!”)

**Critical thinking - How did you run the file? ** An important lesson is how you can create a file and execute the file from command prompt. If you only hit the play button on an IDE how does it run it? You don’t have to answer this but ask yourself how does it do that?

  1. Create a function which prints “hello world!” when called.

No this is not the same as step 5, it's a different take.

When this function is called its job is to return a string value.

  1. Start a python console & import your file.
  2. Make the code from the python file run.
  3. Print that “hello world!” by calling the function you made.
  4. Add this file to git, commit your code and push it

Lists (called Arrays in other languages)

  1. Create a new file listloop.py
  2. Comment on the 3rd line “List script fun”
  3. Add this new file to git, commit your code and push it your repo.
  4. Create a list named numbers.
  5. Populate the following string values into the list in the same order “One”,”two”,”four”,”ten”,”tree”,”six”,”five”
  6. Create a function that when called:
  1. Takes in the list object
  2. Removes the strings “ten”,”six” from the list.
  3. Adds the string “zero” at the beginning the list.
  4. Corrects the spelling of the string “Tree”.
  5. Removes and replaces the list item in the same location with the correct string spelling of “three”.
  1. Commit your code and push it.

Else If Statements and For Loops.

  1. Continue with your last file.
  2. Write a loop to iterate through the list and convert each string to its corresponding integer value. (“one” -> 1)
  3. **Commit and push your changes. **
  4. Make a new function that iterates through the new list [0,1,2,4,3,5]
  5. Loop through the numbers list.

For each item(x) in numbers

  1. Now loop through the range of each value x represents in each iteration.

Look up that python range function.

  1. Inside of the nested loop, the range one.

Print the string “*” for each iteration caused by the range.

Your result should look something like this.

If you are having trouble use print statements to debug/ troubleshoot your code. Is your code doing what you think it's doing? Is it running? Verify all these questions.

  1. **Commit and push your changes. **

Challenge

Change the code so that it prints each nested loop iteration in a single line.

If the range call says 5 make sure the code prints “*” 5 times in the same line.

You are done when it looks like this.

Dictionaries (Called Hashes in other languages)

  1. Create a new file dictloop.py
  2. Comment on the 3rd line “Dictionary script fun”
  3. Add this new file to git, commit your code and push it your repo.
  4. You should now have three different files on your git repository.
  5. Create a dictionary named Fruits
  6. Populate your dictionary with the following key and value pairs: “Strawberry”: 2 “Blueberry”: 3 “Kiwi” : 4
  7. Write a function which calls the Blueberry key of this dictionary and returns its value.
  8. Git Add your file, Commit your code and push it.
  9. Write a new function which prompts the user to enter a string parameter.
  10. The function takes the user input and attempts to get the value for this key from the fruits variable.

Success criteria.

  1. Python console runs your file.
  2. Script Prompts the user for input.
  3. When typing in any of the three fruits it returns the corresponding number.

Scope Creep

The customers don’t know what the numbers mean. They would like to more human friendly information.

Before returning the number add:

  1. The word “dollars” after the number.
  2. The name of the fruit at the beginning of the string
  3. The function should now return the following values:

Strawberry 2 dollars Blueberry 3 dollars Kiwi 4 dollars Great Job! You made it through scope changes!

  1. Commit your code and push it up.

Congrats! Make sure to practice nested loops as in the exercise above the challenge portion is very important.

Please contact me about your completed project so I can review your work and move forward with the next steps.