Workshop 1, Algorithms and Data Analysis
0.1 General Directions for each workshop
You have to work on Google Colab for all your workshops. In Google Colab, you MUST LOGIN with your @tec.mx account and then create a google colab document for each workshop.
You must share each Colab document (workshop) with the following account:
- cdorante@tec.mx
You must give Edit privileges to these accounts.
In Google Colab you can work with Python or R notebooks. The default is Python notebooks.
Your Notebook will have a default name like “Untitled2.ipynb”. Click on this name and change it to “W1-Algorithms-YourFirstName-YourLastname”.
In your Workshop Notebook you have to:
You have to do all the challenges to get full credit for the workshop. The accuracy of the challenge will not significantly affect your grade; completion will have more weight for your workshop grade.
It is STRONGLY RECOMMENDED that you write your OWN NOTES as if this were your personal notebook to study for the FINAL EXAM. Your own workshop/notebook will be very helpful for your further study.
Once you finish your workshop, make sure that you RUN ALL CHUNKS. You can run each code chunk by clicking on the “Run” button located in the top-left section of each chunk. You can also run all the chunks in one-shot with Ctrl-F9. You have to submit to Canvas the web link of your Google Colab workshop.
1 Introduction to Algorithmic thinking
What is an Algorithm?
How to design an algorithm?
Write the problem with your words and with clear and short sentences.
Identify what inputs are needed to solve the problem
Identify what is the output or the final expected result
What is the general approach to solve the problem? Here you specify general steps you will follow in a sequential order.
What is the specific steps for each general step specified above
Pseudocode vs programming code
How can we use LLM’s (such as ChatGPT) to learn how think algorithmically ?
2 Introduction to programming code
What is a programming language? A programming language is a set of commands or instructions that are executed by the computer usually to automate repetitive tasks or functions that usually require intensive data processing. Programming languages are also used to develop computer applications. In Economics and Finance, we use programming languages mainly to do the following:
- data input and/or data collection,
- data cleaning,
- data management including data transformation and data merging,
- data storing,
- data processing that includes descriptive analytics and predictive models, and finally
- information delivery that includes reports or documents usually with summary tables and graphs.
You can effectively perform these programming processes in Python or R.
Python is a free open source language. Nowadays, both Python and R are the two more popular programming languages for Data Science around the world.
2.1 Elements of a programming language
Any programming language has the following elements used to automate any pseudocode to solve any business or technical problem:
Variables and variable types
Conditionals using comparison operators
Loops to do repetitive tasks
Data structures - objects
Data frames
Objetcs
Functions
A function is a method that receives an input (1 or more parameters, which can be variables), do specific steps to process the input, and at the end, return an output which can be one number, one variable with numbers, a data frame, or a complete data structure such as an object.
3 What is an Objet-Programming Language?
Objects:
Classes: Specification of a data structure that contains both properties or variables, other objects, and methods
Object as an instance of a Class
Each object contains data as attributes or properties, and methods (functions) that operate into on the data. The methods are usually functions
4 CHALLENGE 1
You have to write pseudocode and corresponding Python code to calculate the number of months needed to finish paying a mortgage loan. The information about the loan is the following:
Loan amount = $3,000,000.00 pesos
APR (Annual % rate) = 11% (compounded monthly)
Monthly Fixed Payment = $40,000.00 (includes interests and capital)
Your program has to provide 2 results: the number of months needed to finish paying the loan, and the amount of the last payment if the payment is less than the fixed payment amount. Your program has to be able to run with any change in any of the values of the above variables.
Once you wrote your Algorithm as a Text CHUHK, use it as a prompt (or series of promots) for Gemini to generate Python code.
You have to run the Python code and check whether your results are correct.
Pay attention in class about the syntax and logic of Python computer language.
This is a quite challenging exercise!
Hint: if you are familiar with Excel, start solving the problem in Excel, and then try to write your logical steps as pseudocode.
5 CHALLENGE 2
Write pseudocode and corresponding Python code to calculate the price of the following bond issued by the company ABC. ABC needs to finance an important project to develop a new technological device. To get the money, ABC issued a bond with the following characteristics:
- Principal: $3,000,000
- Time to maturity: 20 years
- Coupon rate: 11% (annual)
- coupons are payed semi annually
Calculate the price of this bond if the stated annual interest rate is:
- 8%
- 11%
- 13%
As in the previous challenge, do the same to generate Python code.
6 Datacamp online courses
You will receive an email invitation to register in datacamp.com. Datacamp is one of the best online learning sites for Data Science applied to Business and Finance.
You will receive free access for the whole semester! Accept the invitation to be registered in datacamp.
YUO MUST TAKE Chapter 2 : Control flow and logic from the course: Intermediate Python for Finance
7 W1 submission
The grade of this Workshop will be the following:
Complete (100%): If you submit an ORIGINAL and COMPLETE HTML file with all the activities, with your notes, and with your OWN RESPONSES to questions
Incomplete (75%): If you submit an ORIGINAL HTML file with ALL the activities but you did NOT RESPOND to the questions and/or you did not do all activities and respond to some of the questions.
Very Incomplete (10%-70%): If you complete from 10% to 75% of the workshop or you completed more but parts of your work is a copy-paste from other workshops.
Not submitted (0%)
Remember that you have to submit your Google Colab LINK, and you have to SHARE it with me.