Here are the main data types in Python, along with three examples of each:

  1. Integer (int) – These are whole numbers, both positive and negative.

   a = 5
   b = -10
   c = 0
  1. Float – These are real numbers with decimal points.
  
   a = 3.14
   b = 2.5
   c = -0.5
  1. Boolean (bool) – These are either True or False values.

   a = True
   b = False
   c = 5 > 10
  1. String (str) – These are sequences of characters enclosed in quotation marks.

   a = "Hello, World!"
   b = 'Python is fun!'
   c = "123"
  1. List – These are ordered collections of objects, which can be of any data type.

   a = [1, 2, 3]
   b = ['apple', 'banana', 'orange']
   c = [True, 1, 'hello']
  1. Tuple – These are ordered collections of objects, like lists, but they are immutable (cannot be modified).

   a = (1, 2, 3)
   b = ('apple', 'banana', 'orange')
   c = (True, 1, 'hello')
  1. Dictionary – These are collections of key-value pairs.

   a = {'name': 'John', 'age': 30, 'city': 'New York'}
   b = {'fruit1': 'apple', 'fruit2': 'banana', 'fruit3': 'orange'}
   c = {'bool': True, 'num': 1, 'str': 'hello'}
  1. Set – These are unordered collections of unique elements.

   a = {1, 2, 3}
   b = {'apple', 'banana', 'orange'}
   c = {True, 1, 'hello'}

The highly rated book to learn more about Python data types is “Python for Data Analysis” by Wes McKinney. It covers a wide range of topics related to data analysis using Python, including data types, data manipulation, and visualization. It’s written for intermediate-level programmers who are already familiar with Python basics and want to learn more about using Python for data analysis.

Leave a Reply