Data Types – MyPython Fundamentals

In Python, the following are the commonly used data types:

  1. int (integers) – a whole number that can be positive, negative, or zero. For example: -10, 0, 100.
  2. float (floating-point numbers) – a decimal number that can be positive, negative, or zero. For example: -10.0, 0.0, 100.0.
  3. str (strings) – a sequence of characters. For example: “Hello, World!”, “123”, “abc”.
  4. bool (Boolean values) – a data type with two possible values, True or False. Used to represent binary choices or logical values.
  5. list – an ordered collection of objects. Lists are mutable, meaning the elements of a list can be changed. For example: [1, 2, 3, 4, 5].
  6. tuple – an ordered, immutable collection of objects. Tuples cannot be changed after they are created. For example: (1, 2, 3, 4, 5).
  7. dict (dictionaries) – an unordered collection of key-value pairs. Dictionaries are mutable, meaning their elements can be changed. For example: {“name”: “John”, “age”: 30}.
  8. set – an unordered collection of unique elements. Sets are mutable and can be used to remove duplicates from a list. For example: {1, 2, 3, 4, 5}.
  9. None – a special constant used to represent the absence of a value. For example, when a function doesn’t return a value, it is equivalent to returning None.