KEMBAR78
Chapter 1 | PDF | Python (Programming Language) | Body Mass Index
0% found this document useful (0 votes)
63 views20 pages

Chapter 1

This document introduces Python by discussing that it is a general purpose, open source programming language used for many applications including data science. It describes how to use the IPython shell to execute Python commands and Python scripts to write and run code. The document demonstrates how to define variables, perform calculations, and check variable types in Python. It shows an example of calculating BMI and printing the result to illustrate reproducibility and variable assignment. The key Python types of float, int, string, and boolean are also introduced.

Uploaded by

Ruach Sakadewa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views20 pages

Chapter 1

This document introduces Python by discussing that it is a general purpose, open source programming language used for many applications including data science. It describes how to use the IPython shell to execute Python commands and Python scripts to write and run code. The document demonstrates how to define variables, perform calculations, and check variable types in Python. It shows an example of calculating BMI and printing the result to illustrate reproducibility and variable assignment. The key Python types of float, int, string, and boolean are also introduced.

Uploaded by

Ruach Sakadewa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Hello Python!

INTRODUCTION TO PYTHON

Hugo Bowne-Anderson
Data Scientist at DataCamp
How you will learn

INTRODUCTION TO PYTHON
Python

General purpose: build anything

Open source! Free!

Python packages, also for data science


Many applications and elds

Version 3.x - h ps://www.python.org/downloads/

INTRODUCTION TO PYTHON
IPython Shell
Execute Python commands

INTRODUCTION TO PYTHON
IPython Shell
Execute Python commands

INTRODUCTION TO PYTHON
IPython Shell

INTRODUCTION TO PYTHON
Python Script
Text les - .py

List of Python commands

Similar to typing in IPython Shell

INTRODUCTION TO PYTHON
Python Script

INTRODUCTION TO PYTHON
Python Script

Use print() to generate output from script

INTRODUCTION TO PYTHON
DataCamp Interface

INTRODUCTION TO PYTHON
Let's practice!
INTRODUCTION TO PYTHON
Variables and Types
INTRODUCTION TO PYTHON

Hugo Bowne-Anderson
Data Scientist at DataCamp
Variable
Speci 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

INTRODUCTION TO PYTHON
Calculate BMI
height = 1.79 68.7 / 1.79 ** 2
weight = 68.7
height
21.4413

1.79
weight / height ** 2

weight
BMI = 21.4413
height2

bmi = weight / height ** 2


bmi

21.4413

INTRODUCTION TO PYTHON
Reproducibility
height = 1.79
weight = 68.7
bmi = weight / height ** 2
print(bmi)

21.4413

INTRODUCTION TO PYTHON
Reproducibility
height = 1.79
weight = 74.2 # <-
bmi = weight / height ** 2
print(bmi)

23.1578

INTRODUCTION TO PYTHON
Python Types
type(bmi)

float

day_of_week = 5
type(day_of_week)

int

INTRODUCTION TO PYTHON
Python Types (2)
x = "body mass index"
y = 'this works too'
type(y)

str

z = True
type(z)

bool

INTRODUCTION TO PYTHON
Python Types (3)
2 + 3

'ab' + 'cd'

'abcd'

Di erent type = di erent behavior!

INTRODUCTION TO PYTHON
Let's practice!
INTRODUCTION TO PYTHON

You might also like