This commit is contained in:
counterweight 2023-12-09 18:27:06 +01:00
commit f09ceabf3f
8 changed files with 136 additions and 0 deletions

22
Google Colab 101.md Normal file
View file

@ -0,0 +1,22 @@
## Intro and how to use
Google Colab is a webpage where you can write and run Python code. We will use it for this course and for the Practical Data Science one heavily.
If you have a gmail account, you have access to Colab by default and for free. Since you have a gmail account with UPF, you don't need to register anywhere. To access colab, simply:
- Log into your gmail account
- Head to colab.research.google.com
- Create a new notebook, or open one that is already in your account.
Your notebooks will be saved in your Google Drive automatically. You can also download them if you need them. You can also upload the class notebooks I provide to you in the course to play with them.
## Suggested Additional Materials
- A super brief Colab example
notebook: https://colab.research.google.com/?utm_source=scs-index
- A more detailed, high quality example Colab
notebook: https://colab.research.google.com/github/cs231n/cs231n.github.io/blob/master/python-colab.ipynb
- A brief video intro to Colab (
Spanish): https://www.youtube.com/watch?v=8VFYs3Ot_aA
- Another brief video intro to Colab (
English): https://www.youtube.com/watch?v=oCngVVBSsmA

7
README.md Normal file
View file

@ -0,0 +1,7 @@
This folder contains the materials for the 5-hour Python crash course that runs before my main courses.
Some contents:
- `course_plan.md` : an overview of the contents, the activities and how they are distributed across the different sessions.
- `notebooks`: all the course notebooks, including class, solved exercises and other.
- `Google Colab 101.md`: a small 101 on how to use Google Collab.
- `books`: books that the students can refer to, specially the *Python Crash Course*, which is the backbone of this crash course itself.

Binary file not shown.

Binary file not shown.

104
course_plan.md Normal file
View file

@ -0,0 +1,104 @@
# Intro
The course is divided in five, one-hour long sessions. Each session is divided into two halves, adding up to 10 blocks of 30 minutes. The first and last blocks are the intro and wrap-up, so they are kind of different.
In the even blocks (#2, #4, ...) I introduce new contents and tools to you. I follow some sections of the reference book, so that you can refer to it in case you need help when you are working independently. After those blocks, I challenge you to do certain exercises on your own. Some will come easy, some will be harder.
In the odd blocks (#3, #5, ...) we review the exercises, reflect on what we have learnt and ask questions. These blocks are less content-driven and more student-driven: we will mostly improvise them depending on your questions, how comfortable did you feel with the latest batch of exercises and how playful you are with our new knowledge.
An important note: you are expected to spend time coding yourself. Record this in your mind: programming is not a piece of knowledge that is known, but rather a craft that gets practiced. It's more akin to crafts like carpentry, architecture or running a business than it is to biology, theoretical physics or economics. Unfortunately, this means that no amount of hours of me explaining things to you will truly teach you anything at all. Fortunately, that means that you will need to practice programming yourself, which makes things a lot more fun than just sitting around listening to me. So, just keep in mind you need to find yourself often and long behind the keyboard if you hope to get good at it.
This course has no grades, no assignments and no exam. We are here just for the sake of wonderful learning. I understand that, without the looming threat of deliveries and grading, some people find it a bit difficult to get themselves working. Let me provide some positive motivation with the hope of compensating for that. I can give you two reasons for which engaging passionately with this course might be fruitful for you:
1. Firstly, because Python is the new Excel. Python is an incredible swiss-knife for any knowledge worker, and the ratio between hours invested in learning and useful skills acquired is unbeatable. Being fluent in Python is a great asset, that will make you attractive as a potential hire for companies and will also be a great resource for any endeavor you chase on your own. I can tell you I make a great living by having Python in my toolbelt, and I can also tell you that in many of the cool teams I've worked with, you could not put a foot on the doorstep if you didn't know Python.
2. Secondly, because ramping up your Python skills will help you a lot in our next course together, Practical Data Science for Operations. I can assure you that your future self that will be following that course will be highly grateful for every minute you spent learning hard in this one.
Other important points:
- Course Plan + Is this course right for me?
- Available book.
- All notebooks will be on ecampus.
- Always bring your laptop.
# Contents
- Block 1
- Introduction
- Overview on contents for those wondering: "is this course right for me?"
- Running a hello-world in Google Colab
- Block 2
- Variables
- Data types
- Lists
- Basic list operations
- Take-away work
- Must: Exercise from the book: 2-3 to 2-7 (p. 25), 2-8 and 2-9 (p. 29), 3-1 to 3-3 (p. 36), 3-4 to 3-7 (p. 42), 3-11 (p. 48)
- Extra: Make a composable story with variables
- Advisable: skim through chapter 6
- Block 3
- I show you my composable story
- We go through any questions you have
- We mess around with data types, operations and lists
- Block 4
- Dictionaries
- for looping
- Simulating a production queue
- Take-away work
- Must: Exercises from the book: 6-1 to 6-3 (p. 99), 6-4 and 6-5 (p. 105)
- Extra: Grab my pizza simulator and show insights into how the day went after it finishes.
- Advisable: skim through chapter 5 and 8
- Block 5
- We check your pizza-insights
- We go through any questions you have
- We mess around with dictionaries and lists
- Block 6
- If/else conditionals
- Functions, Revisiting the pizza simulator
- Take-away work
- Must: Exercises from the book: 5-1 and 5-2 (p. 78), 5-3 to 5-7 (p. 84), 8-1 and 8-2 (p. 131), 8-3 to 8-5 (p. 137), 8-6 to 8-8 (p. 142)
- Extra: Compare and understand the two versions of the pizza simulator
- Block 7
- We go through any questions you have
- We learn why functions are important
- Block 8
- Python packages
- Intro to Pandas and Seaborn
- Take-away work
- Find a CSV that you like and plot interesting stuff from it
- Block 9
- We go through any questions you have
- I show you an interesting analysis of the Titanic passenger list
- Block 10
- Where to go from here
- Additional resources
- Most useful stuff for the course
- Farewell
# Farewell
Congratulations! You made it to the end of the crash course in one piece.
Hopefully you have enjoyed it. I can tell you I had enjoyed it a lot. Helping people as they start something as wonderful as programming feels like a privilege.
You have only seen the tip of the iceberg in this course. There is a whole underworld that you can't even imagine right now that starts here. I've been on it for more than a decade now and I can tell you I still have no clue of how deep it goes.
In our course, you will keep on learning more, although we will take the focus out of Python and we will place it on how apply math to operations management, taking Python out of the leading character role and making it a simple tool.
But even so, I encourage you to keep learning. You can do awesome stuff with Python. I have already told you many times how valuable it is in the professional world. But it's also just cool for anything you can picture. I'm going to show you a few cool, random things just to get you hyped up:
- Coldcard
- https://github.com/Coldcard/firmware/tree/master
- Soil moisture sensor
- https://circuitdigest.com/microcontroller-projects/interfacing-soil-moisture-sensor-with-arduino-uno
- Create 3D, printable maps of any city in Spain
- Bring a map to class
- Borrow all the ads of listing pages like Idealista or Milanuncios
- My old stories
- https://www.kaggle.com/code/dejavu23/titanic-survival-seaborn-and-ensembles?scriptVersionId=17964757
## Users
There is access with root user.
There is a user called counterweightoperator. This is the user that runs everything. Use this user.

View file

@ -0,0 +1 @@
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyN8HU6V+ExRbDULNKpqF9hL"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["# Hello world\n","\n","This notebook guides you through printing the text \"Hello world\" on the screen. It has been the most frequent first-step in programming learning for decades. Once you have done it, make sure to tell all your programmer friends to blow their minds away."],"metadata":{"id":"y2rlkNsfReAx"}},{"cell_type":"code","execution_count":1,"metadata":{"id":"fsruidThRXTB","executionInfo":{"status":"ok","timestamp":1673901236629,"user_tz":-60,"elapsed":22,"user":{"displayName":"Pablo Martín","userId":"02780439841798207893"}}},"outputs":[],"source":["# This is a comment. Comments are lines starting with #. \n","# Your Python interpreter (the \"thing\" that works when you hit \"Run\") will always ignore comments.\n","# If you run this block, nothing will happen."]},{"cell_type":"code","source":["# In programming, a string is just a series of characters. Think of it as text.\n","# In Python, strings are represented between single ('') or double quotes (\"\")\n","\"I'm a string.\"\n","'Me too!'\n","\n","# To show something to the screen, you need to \"print it\". \n","# To do that, you make a line of code that reads: print(the_thing_you_want_to_print)\n","# Let's print Hello world\n","print(\"Hello world!\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"PeavZeCoRcvX","executionInfo":{"status":"ok","timestamp":1673901430972,"user_tz":-60,"elapsed":330,"user":{"displayName":"Pablo Martín","userId":"02780439841798207893"}},"outputId":"dc171a4e-3f42-4bf1-f68c-43af6589960b"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["Hello world!\n"]}]}]}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyPJzfE9nnXTzvgWeGviPDyj"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"uP_pKYQytcK9","executionInfo":{"status":"ok","timestamp":1674076113725,"user_tz":-60,"elapsed":29,"user":{"displayName":"Pablo Martín","userId":"02780439841798207893"}},"outputId":"c06e7b90-3a07-4f4f-c9a7-51214f00868c"},"outputs":[{"output_type":"stream","name":"stdout","text":["A long time ago, in the distant land of the Ciutadella Campus, lived a master's student.\n","\n","On the cold nights of February, she enjoyed partying like an animal all day long.\n","\n","But one day, the worse thing ever happened: she had forgotten how to open google colab. It had been 2 days since the\n","last time this had happened.\n","\n","Terrified, the master's student went to visit her Python teacher. After explaining the terrible events to her Python teacher,\n","her Python teacher replied back: 'Oh God, not again Rebeca. It's been 12 times already.'.\n","\n"]}],"source":["story_location = \"the Ciutadella Campus\"\n","pronoun = \"she\"\n","possesive = \"her\"\n","main_character = \"master's student\"\n","enjoyable_activity = \"partying like an animal\"\n","bad_event = \"had forgotten how to open google colab\"\n","time_count = \"2\"\n","time_units = \"days\"\n","savior = \"Python teacher\"\n","saviors_response = \"\"\"'Oh God, not again Rebeca. It's been 12 times already.'\"\"\"\n","\n","story = f\"\"\"A long time ago, in the distant land of {story_location}, lived a {main_character}.\n","\n","On the cold nights of February, {pronoun} enjoyed {enjoyable_activity} all day long.\n","\n","But one day, the worse thing ever happened: {pronoun} {bad_event}. It had been {time_count} {time_units} since the\n","last time this had happened.\n","\n","Terrified, the {main_character} went to visit {possesive} {savior}. After explaining the terrible events to {possesive} {savior},\n","{possesive} {savior} replied back: {saviors_response}.\n","\"\"\"\n","\n","print(story)"]}]}