Welcome!

Hello and welcome! In this class, you will develop computational problem-solving skills by programming in the general purpose Python programing language.

Why Computer Science?

  • Financial motivation: There are many lucrative careers in computer science...
    • Compensation and beneffits are extremely competitive.
    • The payscale range of income for a Software Engineer is between $\$51,521$ and $\$118,417$
    • The payscale range of income for a Machine Learning Engineer is between $\$93,873$ and $ \$129,514$
    • "Not only does computer science provide every student foundational knowledge, it also leads to the highest-paying, fastest-growing jobs in the U.S. economy. There are currently over 500,000 open computing jobs, in every sector, from manufacturing to banking, from agriculture to health care, but only 50,000 computer science graduates a year. " (Computer Science Education Coalition)
    • Note that for specialized computer scientists such as cloud engineers, the expected income is in many cases significantly higher. EG Cloud Engineers starting salary at Amazon is estimated to be over \$100,000k a year
    • Computer Science enjoys a great deal of freedom in the work place.
  • Intelectual Motiviation: There is no shortage of interesting and complex problems to solve...
    • The act of developing code from the ground up helps hone esential problem solving skills.
    • A degree in computer science grants you the freedom to work in almost any field.
    • Seemingly endless oppurtunities for creative work

Why Mathematics and Computer Science?

  • Mathematics is the language of the universe.
  • Computer science heavily leverages concepts from Mathematics.
  • Applying concepts from both fields has lead to major breakthroughs in many areas of study.

Examples of Mathematics and Computer Science in Action

What is Python and who uses it?

  • Python is a powerful open source general purpose programing language.
  • Open source means all of the source code is public.
  • Python has a massive community built around sharing code and ideas.
  • It uses simple syntax making it an excellent choice for a first programing language.
  • Python is leveraged by many companies to build complex web applications including.
    • Disney, Dreamworks, Lucasfilm and many more use python to coordinate massive computer clusters to render blockbuster movies.
  • Is regarded by many as the swiss army knife of machine learning (statistics/data science)
  • More examples at https://www.python.org/about/success/

Philosophy of this Course

  • Abstract Approach
    • Used in mathematics and computer science alike.
    • Once you learn python, learning other languages becomes significantly easier.
    • Ruby, Scala, R are all similar to python.
  • Emphasis on Mathematical Applications.
  • Creativity is Encouraged!
    • Many of the problems you encounter in this class have many possible paths to solutions.
    • "If it is worth proving once, it is worth proving it another way" (Glenn Stephens)

What you will learn

  • Python.
  • Basic $\LaTeX ~~$ typesetting inside Markdown
    • The tool used to typeset mathematical notation.
    • EG $~f(x) = ax^2 + bx + c $
  • Jupyter Notebook
    • The tool used to create this slide show!
    • Code cells, and Markdown cells. This is a markdown cell!

Course Difficulty

  • Coding is difficult but easy in hindsight!
  • You will get stuck on problems, and that is okay!
  • We encourage you to go at your own pace!
  • If you every feel like you aren't being challenged enough, there is no shortage of interesting and difficult problems to solve!
  • "What if I am completely lost all the time?"
    • Feel free to raise your hand and ask questions!
  • And remember... .
  • https://www.youtube.com/watch?v=DN43sCyEanA

Anaconda Distribution of Python

  • Download from https://www.continuum.io/downloads
    • Make sure its python 3!
    • Be sure to pick the correct Operating System (O.S.) (IE Windows, MAC OS, Linux)
    • If this is your first installation of python, feel free to have it auto-setup itself up in paths.

Starting Jupyter

  • Open a Terminal
    • For MAC OS, open your Applications folder, then open the Utilities folder. Open the Terminal application. You may want to add this to your dock.
    • For Windows, you should have a new program called anaconda prompt. Open up this application.
  • In the terminal run jupyter notebook
  • This will bring you to the home page that launches in whatever directory you executed the code from. Note you cannot see files outside of this directory tree
  • Click new and then click python3 to create a new Ipython3 notebook.
  • If you do not want to use Jupyter and would rather develop your code in a usual IDE, type $\texttt{spyder}$ in the command prompt instead. Alternatively, use the Anaconda Navigator that will be installed in folder anaconda was installed to.
  • Alternatively, create a an account at https://cocalc.com/ (Formally known as cloud sage)
  • This is also free! (but now that it is rebraned, the free version is slow!)
  • TODO: add Bindr Support

Writing Your First Program!

  • Traditionally speaking, getting a computer to echo "Hello world!" is the first program that everyone learns.
  • For why this is the case, see https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
  • In order to do this, we will make use of the print() function
  • This function will print anything that is wrapped in quotes to the terminal.
  • For example, print("Welcome to Coding To Calculus!") Will print the message "Welcome to Coding To Calculus!"
  • Try it out yourself now, write a function that prints "Hello World"
In [2]:
# Example: Welcome to Coding to Calculus!
print("Welcome to Coding to Calculus!")
# Put your message below!
print("")
Welcome to Coding to Calculus!

What did we just do?

  • We just told a computer to display the phrase "Hello, world!" to what is called Standard Output.
  • The $\texttt{print}$ function is used to send inputs to standard output (IE, what you will see on your terminal screen)
  • The phrase $\texttt{Hello, world!}$ is wrapped in double quotes " " to tell python that this sequence is what is called a string. You can also use single quotes '' and """"""
  • For our purposes, a string is the data type used to represent text of any kind.
In [4]:
# Practice Problem 1: Get python to print the phrase wubalubadubdub
# Brownie points if you get the referance. 

print("") # Fill me in!
# Notice that if you don't pass in an input to print() it will return a new line 

In [5]:
# Try printing your own custom message!
# You can make the computer print whatever you want...use this power wisely! 
# Notice that this cell is full. 
# To add more space to code, click here and hit enter. 
print("Luke, I am your Father")
print("NOOOOOOOOOOOOOO THATS NOT POSSIBLE")
Luke, I am your Father
NOOOOOOOOOOOOOO THATS NOT POSSIBLE

Writing a Standalone Python Program

  • While the Jupyter notebook environment is a great tool for developing code, but sometimes the ultimate goal is to eventually run it as a standalone python program.
  • To do this, we need to make a file to store out code that ends in .py.
  • For example, we could make a python file called hello.py
  • To do this, open up a text editor
    • I prefer to use Sublime or Atom but you can also use notepad, or spyder (comes with anaconda)
    • Once you open up the text editor, put the following code (with any message you want) into the file: print("foo")
    • Next, save the file as "hello.py"
    • Now you can either open up a terminal and execute python hello.py in the same directory, or you can take advantage of shell shortcuts in the jupyter notebook
      • to execute a bash/batch command in Jupyter, put a ! in the code cell and hit shift + enter
In [11]:
# Example of shell code being executed
!echo Hello World!
Hello World!
In [12]:
# Executing the python script from the terminal 
!python hello.py
Hello World!

Recap

  • Overview of Course structure
  • Motivation for Computer Science and Mathematics
  • Your first program to print a message. ## Next Time:
  • Basic Arithmetic in Python
  • Basic Datatypes in Python