

Data types in python
Presentation
•
Other
•
5th Grade
•
Easy
s tobgyal
Used 11+ times
FREE Resource
12 Slides • 3 Questions
1
Data types in Python
2
Data types in Python
~are used to define the type of a value assigned to a variable
~There are different types of data types in Python
3
Some of the data types are:
String data types: str (text)
Numeric data types: int, float, complex
Boolean type: bool
Sequence types: list, tuple, range
Set data types: set, frozenset
Binary types: bytes, bytearray, memoryview
Mapping data type: dict
4
String/Text
Group of characters/text surrounded by 'single' or "double" quotation marks.
Example:
my_Name= "Sonam Tobgyal@12345"
5
We can also assign multiline string using triple quotes..
Example:
" " "This is an example of
Multiline string used in
Python programming language " " "
6
Multiple Choice
Mr. Torma is a python programmer. He has assinged"Jigdrel Dorji" to the variable my_name. How would you help Torma to print the value assigned in the programme?
input(my_name)
print(my_name)
#my_name
"Jigdrel Dorji"
7
Numbers/numeric:
There are three numeric types in Python
int (whole number)
float (decimal)
complex (real+imaginary)
8
~which represents one of the two values i.e. True or False.
~In programming we often need to know if an expression is
true or false
~When we compare two values, the expression is evaluated and Python returns the Boolean answer:
Example:
1= =1 is True whereas 2<1 is False.
boolean
9
Data type conversion:
~We can convert from one type to another with the int(), float(), and complex() methods:
**We cannot convert complex numbers into another number
int() - integer, a float (by removing all decimals), or a string
Example:
x = int(1) # integer----- 1
y = int(2.8) # floating to integer-----2
z = int("3") # string to integer----- 3
10
Example:
x = float(1) # integer to float---- 1.0
y = float(2.8) # floating to float------2.8
z = float("3") # string to float------3.0
float() - integer, float, string, complex
11
str() - constructs a string from a wide variety of data types, including strings, integer literals and float literals
x = str("s1") # x will be 's1'
y = str(2) # y will be '2'
z = str(3.0) # z will be '3.0'
12
Multiple Choice
What is the data type in python if my_age=25
string
boolean
integer
floating
13
Multiple Choice
Which of the following is not a valid data type in Python?
array
int
float
boolean
14
type function:
~is used to find out the type of data assigned to a variable .
Example:
x=50
print(type(x)) #<class 'int'>
y=2.5
print(type(y))#<class 'float'>
Example:
a="ST"
print(type(a)) #<class 'str'>
b=2+0j
print(type(b))#<class 'complex'>
15
id() function
~is used to get the address of an object where it was stored in memory.
Example:
x="100"
print(id(x))
Data types in Python
Show answer
Auto Play
Slide 1 / 15
SLIDE
Similar Resources on Wayground
12 questions
Animal Adaptations
Presentation
•
5th - 6th Grade
14 questions
Categorical vs. Numerical Data
Presentation
•
5th Grade
8 questions
A SEED TELLS FARMER STORY
Presentation
•
5th Grade
8 questions
Fractions
Presentation
•
5th Grade
12 questions
SIMPLE MACHINES
Presentation
•
4th Grade
10 questions
Rock and Rock cycle
Presentation
•
5th Grade
12 questions
Forces
Presentation
•
5th Grade
9 questions
Types of Energy MELTS Lesson
Presentation
•
5th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade