Data Types in Python Part-2 - PowerPoint PPT Presentation

About This Presentation
Title:

Data Types in Python Part-2

Description:

This Presentation educate you about Data Types in Python, Base conversion, Boolean in python with basic program input and Strings in Python. – PowerPoint PPT presentation

Number of Views:265
Slides: 9
Provided by: Learnbay.Datascience

less

Transcript and Presenter's Notes

Title: Data Types in Python Part-2


1
Data Types in Python
Swipe
2
Data Types in Python
Fundamentals
Derived
Integers Float Complex Boolean String None
List Tuple Range Bytes Bytes Arrays Set Frozen
Set Dictionary
Numbers
Sequence
Sequence
Mapping
3
Base conversion
To convert any number from binary, octal,
hexadecimal to decimal value just assign the
value to a variable with corresponding prefixed
and peint it. It will give you decimal
equivalent of that number.
Bin(X)
Here argument (x) can be a decimal, octal or
hexadecimal value anything
Basic Conversion
oct(X)
hex(X)
4
Boolean
Data type with one of the two built-in values,
True or False. Boolean objects that are equal to
True are truthy (true). But non-Boolean objects
can be evaluated in Boolean context as well and
determined to be true or false. It is denoted by
the class bool.
Python program to demonstrate boolean
type print(type(True)) print(type(False)) print(
type(True))
5
Boolean Data Type in Python
Note True and False with capital T and F are
valid booleans otherwise python will throw an
error.
Boolean in python
True False
  • Except 0 everything is true
  • Except empty string everything is true

True - 1 False - 0
6
Strings in Python
  • In Python, Strings are arrays of bytes representin
    g Unicode characters.
  • A string is a collection of one or more
    characters put in a single quote, double-quote
    or triple quote.
  • In python there is no character data type, a
    character is a string of length one.
  • It is represented by str class.

7
Strings in Python
Combination of characters kept inside
single/double/triple quotes.
Triple quotes are used to -To define multiline
string, -To define docstring. -To comment
multiple lines.
Strings
Indexing - strindex Slicing -
startendstep Few basic operation on
string. -Concatenation. -Repetition.
8
Topics for next Post
Data Types in Python Mutable vs Immutable Data
type in Python Stay Tuned with
Write a Comment
User Comments (0)
About PowerShow.com