{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![Ummah Tech](imgs/logo.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to Python DS Programming"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Welcome to the first session!\n",
    "\n",
    "Assalaamu 'alaykum all! My name is Uthman Apatira and I'll be guiding you through this series.\n",
    "\n",
    "Knowing how to program computers is now a basic skill. Having this knowledge can further your prospects in almost all IT paths. This five part course is intended to help people get acquainted with fundamental python programming knowledge, with an emphasis towards data science:\n",
    "\n",
    "![Session 1](imgs/session1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Session #1\n",
    "- Provisioning an Environment\n",
    "- Install Modules\n",
    "- Elementary Variables\n",
    "- User Input\n",
    "- Searching for Help\n",
    "\n",
    "### Session #2\n",
    "- Syntax and Operations\n",
    "- Lists, Dictionaries\n",
    "- Conditionals\n",
    "- Logic Flow\n",
    "\n",
    "### Session #3\n",
    "- Functions\n",
    "- Object Oriented Programming\n",
    "\n",
    "### Session #4\n",
    "- Numpy and Pandas\n",
    "\n",
    "### Session #5\n",
    "- Comprehensions\n",
    "- Covid19 Survival Simulation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Everything is subject to change, so be sure to keep up with the course material and live lectures. Also, I have a toddler in the house I'm also taking care of so in advance, I ask for your patience and understanding with any interruptions that may result from that..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Class Etiquette"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- If you need to step away for some reason, I won't get offended.\n",
    "- I dislike to mute audience mics. Mute yourselves instead.\n",
    "- Ask questions, get answers. The more you ask, the more you'll be rewarded!\n",
    "- There is homework, and we'll open each sessions discussion the previous session's.\n",
    "- If you look like you're falling asleep, I'll probably ask you a question.\n",
    "- If you don't talk for a while, I'll probably ask you a question.\n",
    "- If you don't ask questions, I'll probably ask you a question.\n",
    "- I'll probably ask you a question."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Provisioning Your Environment"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before you can start programming in Python, you must setup your computer to know how to interpret it. Most of the Python code we write will be inside a Jupyter Notebook environment (the thing you're looking at now!), and a bit will be through Python scripts. For now don't sweat the difference. Just know for now you need to install [Anaconda Python 3.7](https://www.anaconda.com/distribution/) for your Platform: Linux, macOS, or (la haula wala quwwata) Windows.\n",
    "\n",
    "**IMPORTANT**: During the installation process, if Anaconda asks you something about adding PATHS or environment variables, please click YES. This will allow you to execute python, jupyter, etc. from any path / directory. In other word, CHECK BOTH BOXES!\n",
    "\n",
    "![CLICK IT](https://docs.anaconda.com/_images/win-install-options.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here are some step-by-step instructions for getting Anaconda installed on [Microsoft Windows](https://docs.anaconda.com/anaconda/install/windows/).\n",
    "\n",
    "It apparently is also possible to use Anaconda on [Chrome OS](https://unix.stackexchange.com/questions/278494/installing-anaconda-on-a-chromebook), it's just that the setup is not straightforward. You have to put it into developer mode. Then download Anaconda for Linux. Then change the install path to `/usr/local/anaconda3`. One other user was able to do it without going into developer mode, but it is still about a 7 minute process. You can watch [their video instructions](https://www.youtube.com/watch?v=bhM1cCu8uXE) on YouTube here.\n",
    "\n",
    "As a last resort, if all else fails, you can use [Google Colab](https://colab.research.google.com/) to run Python code on the cloud. Just navigate to their website and click on New Notebook. If you're familiar with the Google Suite of products, then it shouldn't take much time to get comfortable with the user interface.\n",
    "\n",
    "Anaconda is probably overkill, the install package has a lot of other bells and whistles you don't need now. But it's all very cleanly contained, so in the future if you want to delete it, you can just remove the directory or use your operating system's uninstall utilities.\n",
    "\n",
    "While that downloads and you set it up, let's talk a bit about Python!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# What is Python?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![Python](imgs/python.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Python is an older language that most people are aware of. It was created in mid 1980s and was named after the British cult-classic comedy `Monty Python`.\n",
    "\n",
    "Python is the language of choice for data scientists because:\n",
    "\n",
    "- It's straightforward to pickup for non-programmers entering into the field, and kids learning how to code.\n",
    "- It's been around long enough that it has a huge supporting community and a lot of documentation available online.\n",
    "- Almost all the new DS research is written in it\n",
    "- Supported and adopted by all the big tech companies (Google, Microsoft, Facebook, ...)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Your Goal?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Have you ever left home, started driving, got on the freeway then asked yourself, \"Where am I going today?\" I'd hope not...\n",
    "\n",
    "Let's make sure you have a SMART goal, something you wish to achieve through the completion of this course. That will facilitate measuring your success.\n",
    "\n",
    "- Why are you taking this course?\n",
    "- What do you hope to accomplish through the completion of this course?\n",
    "- Is there anything you want to be able to build?\n",
    "- How will you know if this class was a success for you?\n",
    "\n",
    "It's important you're able to answer these sorts of questions.\n",
    "\n",
    "**SMART** goals are:\n",
    "\n",
    "1. **Specific**: Well defined, clear, and unambiguous\n",
    "1. **Measurable**: With specific criteria that measure your progress towards the accomplishment of the goal\n",
    "1. **Achievable**: Attainable and not impossible to achieve\n",
    "1. **Realistic**: Within reach, realistic, and relevant to your life purpose\n",
    "1. **Timely**: With a clearly defined timeline, including a starting date and a target date. The purpose is to create urgency."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Programming"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Programming is no more than entering in instructions into a computer, which tell is how to  complete a task.\n",
    "\n",
    "That's one way to define it anyway. By the same token, cooking is nothing more than mixing together ingredients to make a meal, and painting is just slapping colors onto a canvas which absorb light 🙂.\n",
    "\n",
    "There is also an element of creativity in the process in addition to the technical skill. Computers do exactly what they are told, so it's up to you to come up with interesting instructions for the computer to execute upon.\n",
    "\n",
    "Computer programs typically involve storing values into containers called 'variables' and then acting on those variables using basic boolean logic and conditional statements. Programming can be used to:\n",
    "\n",
    "- Make phone, and desktop applications\n",
    "- Create games\n",
    "- Build web pages\n",
    "- Solve equations\n",
    "- Predict future trends\n",
    "- Draw pictures and render graphics\n",
    "- Transact\n",
    "- Etc."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Juptyer Notebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As mentioned earlier, most of the code we write will be inside notebooks that look like this. After you get Anaconda installed, use your terminal / command line program to create and navigate into any directory, and type `jupyter notebook` to launch a new instance:\n",
    "\n",
    "- `mkdir pythonclass`\n",
    "- `cd pythonclass`\n",
    "- `jupyter notebook`\n",
    "\n",
    "This will open up a new tab in your browser:\n",
    "\n",
    "![Notebook](imgs/notebook.png)\n",
    "\n",
    "From there, click `New` and select python to create a new notebook. I recommend you make a new one per class session. Open it up and you're ready to start rocking and rolling."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here are some very handy shortcuts to make using the notebook easier:\n",
    "\n",
    "- `Shift+Return` will execute the current cell.\n",
    "- Tap `b` while in select mode to append an empty code cell.\n",
    "- Tap `a` while in select mode to prepend an empty code cell.\n",
    "- Tap `y` while in select mode to convert the highlighted cell into a code cell.\n",
    "- Tap `m` while in select mode to convert the highlighted cell into a markup cell.\n",
    "- Tap `r` while in select mode to convert the highlighted cell into a raw cell.\n",
    "- Tap the `return` key to enter into the highlighted cell's edit mode.\n",
    "- Tap the `escape` key to leave the currently highlighted cell's edit mode, returning to select mode.\n",
    "- Use the arrow keys to navigate between cells."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Jump into Python"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What is the most important thing to learn how to do when picking up a programming language?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Print"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In python, to display information back to the user, you have to use a `print` statement. `print()` is a special system command that can be used to display / render whatever you _pass_ to it back to the computer display. You may have heard of the term 'Hello, World!'. Let's see if we can do something like that:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('As-Salaamu alaykum!')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It just so happens that in notebooks, the last command you type will automatically be printed, so long as it is not an assignment command. So the above code is equivalent to:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "'As-Salaamu alaykum!'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I'd recommend not taking that shortcut at this juncture of your learning though, especially if you ever plan on using your newfound programming knowledge outside of just notebooks."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Number Variables"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Programming is all about variables. These are containers that you create by naming them and then assigning them a value. You can give your variables almost any name, but they cannot start with a number nor can they contain spaces.\n",
    "\n",
    "Why?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "numA = 10\n",
    "numB = 20\n",
    "\n",
    "print(numA)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Try to write some python code below to get the computer to add your two numeric variables:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO: Go ahead and type code below to complete the above instruction:\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Python supports different variable data types. Above you created numeric variables.\n",
    "\n",
    "- What other data type have you seen already?\n",
    "- What happens when you \"add\" variables of different types?\n",
    "- What about if you \"multiply\" variables of different types?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Dealing With User Input"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What if you want to give the user the ability to enter a value and store it inside of a variable? There's a command you can use for that! It is the `input` command:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "name = input('Type your name: ')\n",
    "print(name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "age = input('Enter your age: ')\n",
    "print(age)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Not bad. Now write a short program which asks the user for their age, adds `10` to it, then displays the final value."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO: Go ahead and type code below to complete the above instruction:\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Booleans"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is one more elementary data type we should cover in this lesson. Boolean values. These variables can only store one of two values: `True` or `False`. You have to pay attention to detail because capitalization matters here. And as you'll see in the future, indentation matters a lot for Python as well."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "raining = True\n",
    "snowing = False\n",
    "\n",
    "print(raining)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also create booleans by evaluating logical expressions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "my_age = 40\n",
    "your_age = 20\n",
    "\n",
    "im_older = my_age > your_age\n",
    "print(im_older)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Searching for Help"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![Programming Joke](imgs/programming.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Knowing how to search for help is cornerstone to becoming an excellent coder! Some tips:\n",
    "\n",
    "- You don't have to write full sentences. Distill your question just down to the most important terms.\n",
    "- It is probably a good idea to start with the name of the programming language you have a question about.\n",
    "- StackOverflow has a lot of great content in it, but sometimes it's dated. So be careful of the response date.\n",
    "- Read the Manuals!\n",
    "- Like any other technical skill, the more you do it, the better you become."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Homework"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. Write a program that asks the user to enter their name, and then says `Assalamu Alaykum` to them, saying their name.\n",
    "1. Write a program that ask the user the enter how many miles they live from Dallas TX, and then convert their response into kilometers\n",
    "1. Write a program that swaps the contents of two variables. For example ***if*** `varA=10`, and `varB=20`, then after the program executes, `varA` should be `20`, and `varB` should be `10`.\n",
    "1. Write a program that asks the user for a number and returns the square of the value.\n",
    "1. Write a program to convert fahrenheit to celsius."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Additional Resources"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- [Command Line (Windows)](https://www.digitalcitizen.life/command-prompt-how-use-basic-commands)\n",
    "- [Terminal (Everyone Else)](https://dev.to/kymiddleton/reference-guide-common-commands-for-terminal-6no)\n",
    "- [Jupyter Notebooks](https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/)\n",
    "- [Python Programming Language](https://en.wikipedia.org/wiki/Python_%28programming_language%29)\n",
    "- [YouTube](http://www.youtube.com) - Almost any question you encounter, there's probably a video tutorial for."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}