80 likes | 99 Views
This Presentation educate you about Data Types in Python, Base conversion, Boolean in python with basic program input and Strings in Python.
E N D
Data Types in Python Swipe
Data Types in Python Fundamentals Derived Suite Integers List Numbers Float Tuple Complex Range Sequence Boolean Bytes String Bytes Arrays Sequence None Set Frozen Set Mapping Dictionary
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 oct(X) Basic Conversion hex(X)
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))
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 True - 1 False - 0 - Except 0 everything is true - Except empty string everything is true
Strings in Python In Python, Strings are arrays of bytes representing 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.
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 - str[index] Slicing - [start:end:step] Few basic operation on string. -Concatenation. -Repetition.
Topics for next Post Data Types in Python Mutable vs Immutable Data type in Python Stay Tuned with