Jupyter Notebook
Look at minute 2:29 of the following video to understand what Virtual Env is.
Let us create a Virtual Environment following the steps in the video! Now watch this second video on Jupyter Notebook:
It is possible to use Jupyter Notebook on browser with Google Colab!
Pandas
A smarter and more abstract tool to handle .csv
files is another Python tool named Pandas
We use Pandas to:
- Manipulate data.
- Visualize and plot data combined with matplotlib library
Install Pandas and Matplotlib
Install pandas in the virtual environment following the instruction available at this web page.
Install matplotlib in the virtual environment following the instruction available at this web page.
Manipulate data
Let us take a look at this presentation.
Keeping Pandas API Documentation at hand with this link, let us see Pandas in action now:
- Create a file named
ManipulateVisualize.ipynb
- Run the Jupiter Notebook in Visual Studio Code (more details here) on the
.csv
dataset Salary Data.csv - Follow and repeat my instructions on your Jupiter!
Exercise Data Manipulation
Given Salary Data.csv:
-
Find the average salary by education level.
-
Add a new column named
"Salary per Year of Experience"
computed as
Recursion
Recursion is a way of programming or coding a problem, in which a function calls itself one or more times in its body. Usually, it is returning the return value of this function call. If a function definition fulfils the condition of recursion, we call this function a recursive function.
Remember, the termination condition:
- A recursive function has to terminate to be used in a program.
- A base case is a case, where the problem can be solved without further recursion. Tips: start by identifying the base case.
- A recursive function terminates, if with every recursive call the solution of the problem is downsized and moves towards a base case.
Let us solve the following exercises, following this approach:
- Write the pseudocode of the solving this exercise using a recursive approach
- Implement the pseudocode in a Python program
Exercise 1
Write a recursive function that accepts two numbers as its argument and returns its power.
Exercise 2
Write a recursive function that calculate sum of first n natural numbers.
Exercise 3
Write a program that reads two integers from keyboard and calculate the greatest common divisor (gcd) using recursive function
Exercise 4
Exercise on Rosalind on RNA.