Fortunato

Let's learn version control!

About me: Dan M.

  • Senior Software Engineer at the Organic Box
  • My past: Software development, Infrastructure Engineering and Network Engineering jobs.
  • Went to school for Electrical Engineering (I don't do that anymore)
  • I like kitties, badminton and development.

Disclaimer:

You can ask questions.

It's okay be stuck, we've all been there.

 

It's okay not to understand everything the first time.

Intro to Version Control

What are we going to do?

Why Python?

Long Term Learning Plan

  • Python

  • Web development with django

  • Version control software

  • Server Administration

  • Databases (lightly)

  • Web servers

  • PCI DSS compliance on a server (a security standard)

  • Data analytics

Learning Plan for today

  • Installation Python

  • Setting up a python workspace.

  • How to write your first application in python

  • Setting up a python project, so that you can easily improve it and test it.

Now Let's go get started!

Installing Python

Windows, Mac, and Linux (Ubuntu)

Windows 10

  • Go to the python windows downloads page https://www.python.org/downloads/windows/
  • Download the "Windows x86-64 executable installer"
  • Once Download just click "Install now" once you have checked the following options options
    • "Install launcher for all users"
    • "Add Python 3.7 to PATH"
  • To adjust your system variables you can take a look at the tutorial attached.

For more info go to: https://www.howtogeek.com/197947/how-to-install-python-on-windows/

Mac

  •  You'll need Homebrew
  • Open a terminal and run the following command:
     

For more info go to:
http://docs.python-guide.org/en/latest/starting/install3/osx/

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  •  Then you'll need to add the following line to the ~/.profile file
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
  • Once home brew is installed you can then just write the following command to install python.
brew install python

Linux (Ubuntu)

  •  Open a terminal and write the following command.
sudo apt install python3

Important Note!

We'll be using Ubuntu for the rest of the talks, and we'll provide a VirtualBox machine for everyone.

Creating a Python Workspace

Pipenv, python and you!

What is a python workspace?

Installing Pipenv

  • I'm only going to be doing the installation for ubuntu (we'll link to other guides)
  • First you'll need pip which is installed by the following command.
 sudo apt install python3-pip 
  • Then you can install pipenv using the following command

For more info go to:http://docs.python-guide.org/en/latest/dev/virtualenvs/#virtualenvironments-ref

pip install --user pipenv
  • Andrew will be speaking more about the commands later on.

Writing your first application

Fortunato

The first iteration.

Things we'll learn writing our first program

  • Printing things to the screen
  • Taking user input
  • if statements
  • for loops
  • while loops
  • functions
  • Tying it all together to create Fortunato.

Print to a screen

  •  Create a new file called print.py
  • Edit the file and write the following
print("I love dans cats, and i wished that he showed them more.")
  • To run the following program that you wrote
python3 print.py
  • The output of the program should be as follows:
I love dans cats, and i wished that he showed them more.

Yay you just created your first program!

Taking user input!

  •  Create a new file called user_input.py
  • Edit the file and write the following
name = input("what is your name? ")
print("Hello {}!".format(name))
  • To run the following program that you wrote
python3 user_input.py
  • The output of the program should be as follows if you entered "Dan"
Hello Dan!

Yay you just taken in some user input #goals

If statements

  •  Create a new file called master_if.py
  • Edit the file and write the following
name = input("what is your name? ")

if name == 'Dan':
    print("Hello Master {}!".format(name))
  • To run the following program that you wrote
python3 master_if.py
  • The output of the program should be as follows if you entered "Dan"
Hello Master Dan!

You should only see output if the name is Dan

Else statements

  •  Edit the file called master_if.py
  • Edit the file and write the following
name = input("what is your name? ")

if name == 'Dan':
    print("Hello Master {}!".format(name))
else:
    print("Hello {}, I guess....".format(name))
  • To run the following program that you wrote
python3 master_if.py
  • The output of the program should be as follows if you entered "Steve"
Hello Steve, I guess....

Now you can greet anyone!

For statements

  •  Edit the file called for.py
  • Edit the file and write the following
age = input("what is your age? ")

dots = ''
for i in age:
    dots += '.'

print(dots)
  • To run the following program that you wrote
python3 for.py
  • The output of the program should be as follows if you entered "3"
...

For statements allow you to go through a list of things!

Functions!

  •  Edit the file called function.py
  • Edit the file and write the following
def get_fortune(name, age):
    print("Hello {} year old {}, and your lucky numbers are 3 5 6".format(age, name))

name = input("Please enter your name: ")
age = input("Please enter your age: ")

get_fortune(name, age)
  • To run the following program that you wrote
python3 function.py
  • The output of the program should be as follows if you entered "Dan" as a name and "28" as an age.
Hello 28 year old Daniel, and your lucky numbers are 3 5 6

Functions give you simplify code you you wrote

While loops and breaks

  •  Edit the file called while.py
  • Edit the file and write the following
def get_fortune(name, age):
    print("Hello {} year old {}, and your lucky numbers are 3 5 6".format(age, name))

while True:
    fail_condition = input('Do you want your fortune? ("x" to quit, or enter to continue)\n')
    if fail_condition == 'x':
        break
    name = input("Please enter your name: ")
    age = input("Please enter your age: ")
    get_fortune(name, age)
    print('Thank you! \n\n')
  • To run the following program that you wrote
python3 while.py

This program will always run unless you enter 'x'

Congratulations Fortunato just got a $500 valuation from your investors!

Next Step is to create a project

Congrats on the early prototype though!

Creating a project for Fortunato

The second iteration of fortunato.

What we'll be covering in our project today

  • Files we'll talk about 
    • README.rst
    • AUTHORS
    • setup.py
    • setup.cfg
    • MANIFEST.in
  • Python objects (and Object oriented programming)
  • Testing
  • Coverage
  • Linting
  • How cute Dan's cats are

Important files for our project

Pipenv and our isolated workspace

pipenv install -e .
pipenv install -d -e .[dev]

Useful commands for pipenv that we'll be using

This is going to create two files for us that are important:

  • Pipfile
  • Pipfile.lock

Fortunato

The second iteration!

Testing & Coverage

Pylint

Congratulations Fortunato just got a $1000 valuation from your investors!

(which is at least more than last time.)

Making Fortunato use version control (Git Basics)

By Daniel Mouris

Making Fortunato use version control (Git Basics)

  • 80
Loading comments...

More from Daniel Mouris