Learn Data Types in python for the absolute beginner (2021 grasp basic python online with role model)

Learn Data Types in python for the absolute beginner (2021 grasp basic python online with role model)

 

what are the data types in python, how many types are there



What are the data types in python: 

-> In python programming language data type was a key concept 

->  All the variables are used stored in the data types 

-> The python programming language also has some builtin data types 


  • str                           -> This data type is used for Text type 
  • Int, float, char       -> These three data types are numeric data types
  • List, tuple, range   -> These are said to be the sequence data type
  • dict                          -> This data type is a Mapping type 
  • set, forenzset          -> These are said to be set data types 
  • bool                         - > This data type belongs to the boolean department 
  • byter, byteraay , memoryview       -> These are said to be binary data types 


How to Get a data type: 

You can get the data type of anything by using the function type()

Example: 

x = 25
print(type(x)

output: 25 
            <class int> 


Python Numbers: 

There are three numeric types in the python programming language 

  • Int 
  • Float 
  • Char 

->  The variables of numeric types are created when you assign a value to it

-> The "int()" data type is used for normal numbers

-> The "float()" data type is used for number along with points

-> The "char()" data type is used for the alphabet along with the number 


Example: 

x = 5  #int 

x = 5.25 #float 

X = j5 #complex


-> to verify the data type of the variable you need to use the type() function 



Type conversion: 

By using the type conversion we can convert one data type to another data type like int() to float () etc


Random Number: 

Python language does not have a function random to make a random number but it has a separate module called random that can be used to make random numbers 

Example:

import random 

print(random.randrange(1,10))

output;  2

Post a Comment

Previous Post Next Post