Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

Datatypes

STARTER - SPLAT SPLAT


Explain each splat in one sentence.

**
* variable
operand

+ Value

/ - %
print Python operator
STARTER – WILL THIS PROGRAM RUN?
OBJECTIVES

•Identify and compare various


datatypes while giving examples for
them
SUCCESS CRITERIA
You Must: Be able to identify between a string and an integer

You Should: Differentiate between integer and float

You Could: Explain the datatype of any given data and give
examples for it
• Datatypes are the different types of data you can have
WHAT ARE in Python.
DATATYPES ? • Think of it like putting things in containers, liquids
must be put in glasses/bottles, rice in a pot and so on
Data Types
Think back to when we learned about Variables.
A variable is like a box. Each box has a name, and we can store a
value in each box.
When we store a value in a Python program, we need to know
the data type of that value.

name=‘Monty’ “Monty”
What type of
data is
print(name) “Monty” ?
na m e
WHAT ARE DATATYPES ?
• For example, if you want to store your age in a
variable, you need to use Integers.
• But if you want to store your name in a variable, is an
Integer useful ?

• What can you use instead?


Data Types
Python has 4 data types:
• String (text or alphanumeric information, enclosed in double/single
quotes);
• Integer (a whole number, with no decimal point);
• Float (a number with a decimal point);
• Boolean (can only be one of two values, True or False).

‘XYZ’ 47 23.68 False

String Integ Float Boole


er a n
Data Types
Which data type is this value?
Float 3.142

String Integ Float Boole


er a n
Data Types
Which data type is this value?
String Monty

String Integ Float Boole


er a n
Data Types
Which data type is this value?
Boolean True

String Integ Float Boole


er a n
Data Types
Which data type is this value?
Integer 47

String Integ Float Boole


er a n
Data Types
Which data type is this value?
String “1234”
Did this answer surprise you?
Any data enclosed within
“quotes” is always a string!

String Integ Float Boole


er a n
Data Types
Which data type is this value?
Integer -23

String Integ Float Boole


er a n
TASK 1
Data Datatype
Identify the datatype of the given data. True

‘Qatar’

‘W’

68.95

57
TASK 1 – SAMPLE ANSWER
Data Datatype
Identify the datatype of the given data. True Boolean

‘Qatar’ String

‘W’ String

68.95 Float

57 Integer
type()
• In Python, the type() function will print the datatype of the variable you wish
to know. Use print along with type() to get the output on the screen

print(type(10))

• This will give output as Integer.


TASK 1 – SAMPLE ANSWER
Data Datatype
Check your answers of Task 1 by printing True Boolean
out the type of each data in Python.
‘Qatar’ String
Save the screenshot of each answer in ‘W’ String
your Class Notebook – total 5
screenshots 68.95 Float

57 Integer
TASK 2A
Data Datatype
‘m’ Boolean
Draw lines to match the data with its
correct datatype. 79 String

False Float

‘I love ICT’ Integer

19.99 String
TASK 2A - ANSWER
Data Datatype
‘m’ Boolean
Draw lines to match the data with its
correct datatype. 79 String

False String

‘I love ICT’ Float

19.99 Integer
TASK 2B

Come up with at least 2 examples of Data type Example


each data type Integer

Boolean

Float

String
TASK 2B – SAMPLE ANSWER

Come up with at least 2 examples of Data type Example


each data type Integer 5, 64

Boolean
True, False
Float 5.5 , 3.200

String
‘Al Arqam’, ‘i’
TASK 2C
Fill in the table below. One example is done for you:
Data Example Data Type
Age 13 Integer
Name
Test tomorrow?
Y/N
Weight
Price
TASK 3– SAMPLE ANSWER
Data Example Data Type
Age 13 Integer
Name ‘Dana’ String
Test tomorrow? ‘Y’ String
Y/N
Weight 24.59 Float
Price 19.99 Float
KEYWOR
D S
Plenary String
Float
Boolean
Integer
Quizizz Quiz

https://quizizz.com/admin/quiz/65127de75a1
48a5c951095b3?source=quiz_share
KEYWOR
D S
Plenary String
Float
Boolean

Explain the difference between Integer

Integer
3
Float
3.0
“3” String

“3.0” String
RECAP
Remember:
• String holds alphanumeric data (text, numbers and
punctuation) as text
• Integer holds whole numbers
• Float holds numbers with a decimal point
• Boolean holds True or False only

MEET IT I know the difference between a string and an integer


DID BEAT IT
I know the difference between integer and float
YOU ?
SMASH IT
I know to give examples for different datatypes, and identify
any given data!

You might also like