Search Header Logo
Data Types - Python

Data Types - Python

Assessment

Presentation

Computers

Vocational training

Practice Problem

Easy

Created by

Sakxam Shrestha

Used 6+ times

FREE Resource

20 Slides • 8 Questions

1

media

Data Types

American Baptist College

2

media

Objective: Data Types

What are they?
Why are they important?
Examples

3

media
media
media

Software

Hardware

1100 1001
1101 0111
0010 1101
1001 1001

while cond != True:
instr = gen_inst()
cond = eval(instr)
return instr

Understands “Binary Code”

Instructions

Understands Human

instructions

Compiler

This Class

4

media

There are many different programming languages…

Python

Scratch

Java

C/C++

Javascript

Go

R

Swift

Languages


Python
Compiler

10110110 00111001
10011010 11111001
11000101 00000001

Machine Language (Binary)

Java Compiler

C++ Compiler

int num_people = 5

uint32_t num_people = 5

Programming Language (Python)

Programming Language (Java)

Programming Language (C++)

This Class

num_people = 5

5

media
media

6

media

The rules for placement

and ordering of words and

symbols in a programming

language.

like “grammar” in a human

language

Syntax
Concepts vs. Syntax

The concepts are the same

across programming, but

the syntax changes between

programming languages.

7

media

Types of learning in this class

Type 1

Concept you already know

New “syntax”

Type 2

New Conceptand New “syntax”

Examples

Math operators (+, -, *, /)

Variables (y = mx + b)

Examples

Functions

Recursion

Dictionaries

8

media

Learning Languages

Words

Phrases

Sentences

Values

Expressions

Statements

Data Types

Parts of speech

9

media

Data Types: What are they?

The categorization / classification of data values.

They indicate to the computer how the programmer

intends to use the data.

Building blocks of computer science and

programming.

10

media

Our first four data types

1. integer
2. float
3. string
4. boolean

11

media

Data Types: integer (int)

Whole numbers
Can be positive or negative
No decimal places

Commonly abbreviated as int

5

-40

0

13382

12

media

Data Types: float

Decimal numbers
Can be positive or negative

Comes from term floating point number

Commonly abbreviated as float

3.14159

2.0
-9.5

13

media

Recap: Numbers

integers or floats
integers are whole numbers, e.g. 3
floats are numbers with a decimal, e.g. 3.14

14

media

😴 Why does integer vs float matter?

Computers are faster at doing math with integers
Floats sometimes don’t make sense. Ex: can you be in 2.35th
place in a race?
Ints sometimes don’t have enough information. Ex: student
GPA

15

Multiple Choice

What is the data type of the number 7.0 in Python?

1

Integer

2

Float

3

String

4

Boolean

16

Multiple Choice

Which of the following numbers is considered an integer?

1

3.14

2

-2.0

3

0

4

5.5

17

Multiple Choice

What is the result of the (15 / 4) in Python?

1

Integer

2

Float

3

String

4

Boolean

18

media

Data Types: string (str)

Text (sequence of characters)
Surrounded by quotes (either

single or double)

Always interpreted as string

when in quotes, even if
resembles a number

Commonly abbreviated as str

'abcdefg'
“Hello!”
'3.14'

19

media

Why double quotes and single quotes?
“Hello!” or 'Hello!'
‘My name’s Jake’

Data Types: string (str)

“My name’s Jake”

“Hello!’ or 'Hello!”

20

media

Data Types: boolean (bool)

True or False
Used to express a conditional

value
E.g. whether you are tall

enough to ride a roller coaster

E.g. whether two things are

the same or not

Commonly abbreviated as bool

True
False

21

media

Data Types: Why are they important?

Do different things
Example: can do arithmetic (add, subtract, multiply, divide)
on integers and floats, but not on strings and booleans

22

Multiple Choice

What is the data type of the value "3" in Python?

1

Integer

2

Float

3

String

4

Boolean

23

Multiple Choice

Which of the following values is considered a boolean?

1

0

2

'True'

3

True

4

3.14

24

Multiple Choice

What is the data type of 3.5 in Python?

1

Integer

2

Float

3

String

4

Boolean

25

Multiple Choice

Which of the following values is a string?

1

7

2

True

3

'7'

4

7.0

26

Multiple Choice

What is the data type of False in Python?

1

Integer

2

Float

3

String

4

Boolean

27

media

Data Types: integer, float, string, boolean

Data Type

Definition

Value Examples

integer (int)

number without a decimal point

5, -40, 0, 13382

float

number with a decimal point

3.14, 2.0, -9.5

string (str)

sequence of characters surrounded by quotes

‘abc’, “Hi!”, ‘3.14’

boolean (bool)

True or False

True, False

28

media

Questions?

media

Data Types

American Baptist College

Show answer

Auto Play

Slide 1 / 28

SLIDE