In Python, all python global variables include string and number are object variables. No matter that is a string or number, a python programmer does not need to declare the data type of that variable before using it because that object will be automatically converted to the related data type during the run time based on the type of that variable which has been assigned to that object.

Below are various data types in Python:

  1. string
  2. integer
  3. float
  4. complex
  5. list
  6. tuple
  7. range
  8. dict
  9. set
  10. frozenset
  11. bool
  12. bytes
  13. bytearray
  14. memoryview


Here are the examples of a few data types we have often used in the Python program.

# Python identifier is a name used to identify a variable
decimal_number = 3.0
hello = "Hello World!"
true_ = True
just_number = 6

We can use the type method to find out what is the data type for a particular object in python, for example, the below code will produce the following outcome!

hello = "the wonderful world"
print(type(hello))
This python object belongs to the string type

Given: Print three times “Hello World!” within a while loop.

hello = "Hello World!" # declare "hello world" string
count = 2 # declare the count variable
true_ = True

# Print "Hello World!" phrase three times
while(true_):
    print(hello)
    count -= 1 # minus one
    if(count < 0):
        true_ = False

What the above Python program does is to set a count variable within the while loop that will control the number of times to print the “Hello World!” phrase on the screen!

We will constantly use each of the above Python data types in our future tutorials on different Python codes such as the Python’s loop program which we have mentioned above!

Please follow and like us:

Leave a Reply

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