In this tutorial, we will learn about the Keywords in Python, and Datatypes or its types, and how to use them with the help of examples.

Define Keywords in Python

Keywords are the words provided by Programming language those have special meaning or work within the program. Keywords cannot be use as user define identifier.

Python contains thirty nine (39) keyword in the most recent version, i.e., Python 3.11.1 Here we have shown a complete list of Python keyword.

Falseawaitelseimportpass
Nonebreakexceptinraise
Trueclassfinallyisreturn
andcontinueforlambdatry
asdeffromnonlocalwhile
assertdelglobalnotwith
asyncelififoryield
iskeywordkwlistissoftsoftkwlist
Keyword

Data Types in Python

Data types are the reserved words that specify the specific type of value stored by a variable.

  • Numeric
  • Boolean
  • Sequence Types
  • Sets
  • Dictionaries

Numeric Data Types

It is describes the numeric value & decimal value. Number stores numeric values & decimal value. The integer, float, and complex values belong to Numeric data-type in Python. Python provides the type() function. These are immutable modifications are not allow.

Python supports three types of numeric data.

  • Int
    • Integer value can be any length
    • Such as 12, 22,85, -12,-22, etc.
  • Float
    • It is store floating point numbers
    • Such as 1.5 , 2.5 , etc.
  • Complex
    • It is contains an order pair
    • such as a + ib

Example of Numeric Data Types

print("Type of x: ", type(24)) 
   
print("\nType of y: ", type(9.0)) 
   
z = 8 + 12j
print("\nType of z: ", type(z))
Example of Numeric Data Types

Let’s run the code

Example of Numeric Data Types
Output Value

Boolean Data Types

Boolean data type represent two values, True and False. True means 0 and False means 1. Logical operators and or not return value is Boolean.

Example Boolean data type

print(type(True))
print(type(False))
Example Boolean data type

Let’s run the code

Example Boolean data type
Example Boolean data type

Sequence Types

There are three types of Sequence Types

  • Strings
    • Represent group of characters
    • Declared with in single or double or triple quotes
    • It is immutable modifications are not allowed.
  • List
    • Group of heterogeneous objects in sequence.
    • This is mutable modifications are allowed
    • Declared with in the square brackets [ ]
  • Tuple
    • Group of heterogeneous objects in sequence
    • This is immutable modifications are not allowed.
    • Declared within the parenthesis ( )

Example

#Strings
str = "Basic Engineer"  
print(str)  
#list
list1  = [1, "basic", "engineer", 2]      
print(type(list1))
#Tuples
tup = ("basic", "engineer", 1)      
print (type(tup)
Example of String, List and Tuples

Let’s run the code

Example of String, List and Tuples
Example of String, List and Tuples

If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.

To know more about Python Wikipedia please click here .

Stay Connected Stay Safe, Thank you


Basic Engineer

Hey Readers! We have more than fifteen years of experience in Software Development, IoT, Telecom, Banking, Finance and Embedded domain. Currently we are actively working on Data Science, ML and AI with multiple market leaders worldwide. Happy Reading. Cheers!

0 Comments

Leave a Reply

Avatar placeholder

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