Homework 0 –
Objective: The purpose of this homework is for you to gauge how proficient you are at Python
and following directions. This course provides very specific instructions on how to submit
assignments/final project, so please READ all instructions and follow them properly.
How to do this assignment: Using Google Colab (https://colab.research.google.com/) please
answer the following questions in a new notebook. You are to write the question on a Text field,
and your programming answer on a Code field. Please write your name and student ID number
on a Text field at the very beginning of this notebook. Note that when you are testing your
functions, the output needs to be shown
What to submit: Via iCollege you are to download a copy of the executed Colab notebook in
PDF format, and submit this file ALONGSIDE a link (in the comments/description section) to
your own GitHub repository where this Colab notebook is stored. In other words, you are
expected to keep your own personal GitHub repository for this class and place ALL your
assignments and project code in that location.
Questions (100 total points): NOTE: You cannot use any libraries or system
functions for any of these tasks.
1. Write a function that finds the factorial of a number. Test the function finding the
factorial of the number 10.
2. Write a function that determines if a number is a prime number. Test the function with
the following numbers: 3 and 1251.
3. Write a function that transposes a matrix. Test with a 3 x 3 identity matrix.
4. Using Pandas and Numpy, write a piece of code to combine two series into one. Test
your code with:
series1 = pd.Series(np.arange(10))
series2 = pd.Series(np.arange(26))
Do not forget to set the seed, or your answer won’t be reproducible.
5. Using pandas, write a piece of code to convert the first character of each element in a
series to uppercase. Test your code with:
series = pd.Series([‘nlp’, ‘will’, ‘be’, ‘easy?’])
Bonus: Using pandas, write a piece of code to get the frequency of unique values in the
entire dataframe (not using built in functions). Test your code with:
dataFrame = pd.DataFrame(np.random.randint(5, 10, 20).reshape(-1, 4), columns = list(‘abcd’))