19
Hello Python! INTRODUCTION TO PYTHON Hugo Bowne-Anderson Data Scientist at DataCamp

Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

Hello Python!I N T R O D U C T I O N TO P Y T H O N

Hugo Bowne-AndersonData Scientist at DataCamp

Page 2: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

How you will learn

Page 3: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python

General purpose: build anything

Open source! Free!

Python packages, also for data science

Many applications and �elds

Version 3.x - https://www.python.org/downloads/

Page 4: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

IPython ShellExecute Python commands

Page 5: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

IPython Shell

Page 6: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python ScriptText �les - .py

List of Python commands

Similar to typing in IPython Shell

Page 7: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python Script

Page 8: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python Script

Use print() to generate output from script

Page 9: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

DataCamp Interface

Page 10: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

Let's practice!I N T R O D U C T I O N TO P Y T H O N

Page 11: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

Variables and TypesI N T R O D U C T I O N TO P Y T H O N

Hugo Bowne-AndersonData Scientist at DataCamp

Page 12: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

VariableSpeci�c, case-sensitive name

Call up value through variable name

1.79 m - 68.7 kg

height = 1.79

weight = 68.7

height

1.79

Page 13: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Calculate BMIheight = 1.79

weight = 68.7 height

1.79

BMI =

68.7 / 1.79 ** 2

21.4413

weight / height ** 2

21.4413

bmi = weight / height ** 2

bmi

21.4413

height2weight

Page 14: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Reproducibility

height = 1.79

weight = 68.7

bmi = weight / height ** 2

print(bmi)

21.4413

Page 15: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Reproducibility

height = 1.79

weight = 74.2 # <-

bmi = weight / height ** 2

print(bmi)

23.1578

Page 16: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python Types

type(bmi)

float

day_of_week = 5

type(day_of_week)

int

Page 17: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python Types (2)

x = "body mass index"

y = 'this works too'

type(y)

str

z = True

type(z)

bool

Page 18: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

INTRODUCTION TO PYTHON

Python Types (3)

2 + 3

5

'ab' + 'cd'

'abcd'

Different type = different behavior!

Page 19: Hel l o Pyth o n...I NTR O D U CTI O N TO P Y THO N Python G en eral p u rp o s e: b u ild an yt h in g O p en s o u rce! Free! P yt h o n p ackages , als o fo r d at a s cien ce M

Let's practice!I N T R O D U C T I O N TO P Y T H O N