Types in Python Explained- Built-in Data types

by | Nov 25, 2020 | Python | 0 comments

Next chapter to ‘My First Python Program and Introduction to Jupyter Notebooks’ is ‘Types in Python’. I am following The course in “Python For Data Science” at cognitiveclass.ai and these Posts are way of me documenting what i have learnt.

Built-in Data types

Python Programming/Data Types – Wikibooks is one good read that you must not miss. You can also read Built-in Types — Python 2.7.14 documentation which is advance at this stage.

Python’s built-in (or standard) data types can be grouped into several classes. Sticking to the hierarchy scheme used in the official Python documentation these are numeric types, sequences, sets and mappings (and a few more not discussed further here). Some of the types are only available in certain versions of the language as noted below.

Boolean

the type of the built-in values True and False. Useful in conditional expressions, and anywhere else you want to represent the truth or falsity of some condition. Mostly interchangeable with the integers 1 and 0. In fact, conditional expressions will accept values of any type, treating special ones like boolean False, integer 0 and the empty string "" as equivalent to False, and all other values as equivalent to True. But for safety’s sake, it is best to only use boolean values in these places.

Numeric types

  • int: Integers; equivalent to C longs in Python 2.x, non-limited length in Python 3.x
  • long: Long integers of non-limited length; exists only in Python 2.x
  • float: Floating-Point numbers, equivalent to C doubles
  • complex: Complex Numbers

Sequences

  • str: String; represented as a sequence of 8-bit characters in Python 2.x, but as a sequence of Unicode characters (in the range of U+0000 – U+10FFFF) in Python 3.x
  • bytes: a sequence of integers in the range of 0-255; only available in Python 3.x
  • byte array: like bytes, but mutable (see below); only available in Python 3.x
  • list
  • tuple

Sets

  • set: an unordered collection of unique objects; available as a standard type since Python 2.6
  • frozen set: like set, but immutable (see below); available as a standard type since Python 2.6

Mappings

  • dict: Python dictionaries, also called hashmaps or associative arrays, which means that an element of the list is associated with a definition, rather like a Map in Java.

Now coming to course you can refer to course video for topic, very informative indeed.

Type Casting in Python

Converting from one object type to a different object type

You can change the type of the object in Python; this is called typecasting. For example, you can convert an integer into a float, as in 2 to 2.0.

For Detailed explanation refer the Course.

Watch the Video:-

Join Today

Know more about latest trends, News in Field of Data Analytics.

We will offer Free SAS and Python Programme in Data Science & enhance your understanding of data analysis.

By rlochan2021

We offer Everything Free here and always will be, so joining is Risk Free and Always Cost Free.

Check Out These Related Posts

Functions in Python Programming for Data Science

I am really impressed with two online courses one is “Analytics in Python” at edX by ColombiaX and another is “Python for Data Science” at cognitiveclass.ai or (Previously Bigdatauniversity). So i am going to document what ever i will learn about functions in these two courses. First there are Built-in functions(Ready made for use), such […]

read more

String Functions in SAS and Python

I always believe SAS and Python can make a great team together for Data Scientists. So Why Now we study them together. In this Post we will discuss various String functions in SAS and Python. String Functions in Python 3 Hope you must have gone through my previous post “Python Programming- Strings explained“. len(): returns […]

read more

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *