

Data Types - Python
Presentation
•
Computers
•
Vocational training
•
Practice Problem
•
Easy
Sakxam Shrestha
Used 6+ times
FREE Resource
20 Slides • 8 Questions
1
Data Types
American Baptist College
2
Objective: Data Types
What are they?
Why are they important?
Examples
3
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
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
6
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
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
Learning Languages
Words
Phrases
Sentences
Values
Expressions
Statements
Data Types
Parts of speech
9
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
Our first four data types
1. integer
2. float
3. string
4. boolean
11
Data Types: integer (int)
• Whole numbers
• Can be positive or negative
• No decimal places
Commonly abbreviated as int
5
-40
0
13382
12
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
Recap: Numbers
integers or floats
integers are whole numbers, e.g. 3
floats are numbers with a decimal, e.g. 3.14
14
😴 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?
Integer
Float
String
Boolean
16
Multiple Choice
Which of the following numbers is considered an integer?
3.14
-2.0
0
5.5
17
Multiple Choice
What is the result of the (15 / 4) in Python?
Integer
Float
String
Boolean
18
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
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
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
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?
Integer
Float
String
Boolean
23
Multiple Choice
Which of the following values is considered a boolean?
0
'True'
True
3.14
24
Multiple Choice
What is the data type of 3.5 in Python?
Integer
Float
String
Boolean
25
Multiple Choice
Which of the following values is a string?
7
True
'7'
7.0
26
Multiple Choice
What is the data type of False in Python?
Integer
Float
String
Boolean
27
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
Questions?
Data Types
American Baptist College
Show answer
Auto Play
Slide 1 / 28
SLIDE
Similar Resources on Wayground
22 questions
Pelatihan Aplikasi Quizizz
Presentation
•
KG
19 questions
analysis of account
Presentation
•
KG
19 questions
10.2 Marching Band
Presentation
•
KG
19 questions
Bijak menggunakan sosial media
Presentation
•
KG
22 questions
Clause
Presentation
•
KG - Professional Dev...
20 questions
Asesmen Formatif 1.1 KPJ XI TJKT
Presentation
•
KG - University
25 questions
Introduction to Project Management - Slides
Presentation
•
KG
21 questions
PEMANTIK Kelas Penggerak Sleman
Presentation
•
KG
Popular Resources on Wayground
15 questions
Grade 3 Simulation Assessment 1
Quiz
•
3rd Grade
22 questions
HCS Grade 4 Simulation Assessment_1 2526sy
Quiz
•
4th Grade
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
20 questions
Math Review
Quiz
•
3rd Grade