2

Basic data types (numbers, strings, lists, Tuples, Dictionaries, Booleans, Sets, None) in python

Blogprogrammingpythonpython programming course

In Python, there are several basic data types that are used to store and manipulate data. These include:

  • Numbers: There are several types of numbers in Python, including integers (whole numbers), floats (decimal numbers), and complex numbers. Here are some examples:
  • Strings: Strings are sequences of characters and are used to store text. They can be declared using single or double quotes. Here are some examples:
  • Lists: Lists are used to store ordered collections of items. They are declared using square brackets and items are separated by commas. Here are some examples:
  • Tuples: Tuples are similar to lists, but they are immutable, meaning their elements cannot be changed once they are created. They are declared using parentheses and items are separated by commas. Here are some examples:
  • Dictionaries: Dictionaries are used to store key-value pairs. They are declared using curly braces and items are separated by commas. The keys and values are separated by colons. Here are some examples:
  • Booleans: Booleans are used to represent true or false values. They are declared using the keywords True and False. Here are some examples:
  • Sets:  A set is a collection of unique items. In other words, a set does not allow duplicate values. Sets are defined by curly braces {} or the built-in set() function. Here is an example of how to create and use a set in Python:
  • None: In Python, None is a special value that represents the absence of a value or object. It is similar to null in other programming languages. It is an object of NoneType. It is commonly used to indicate that a variable has no value assigned to it. Here’s an example of how to use None in Python:

In python None also represents the null value of an object.

These are the basic data types in python and you can use them to store and manipulate data in your python programs.

One Comment

Leave a Reply

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