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.
False | await | else | import | pass |
None | break | except | in | raise |
True | class | finally | is | return |
and | continue | for | lambda | try |
as | def | from | nonlocal | while |
assert | del | global | not | with |
async | elif | if | or | yield |
iskeyword | kwlist | issoft | softkwlist |
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
Example of Numeric Data Typesprint("Type of x: ", type(24)) print("\nType of y: ", type(9.0)) z = 8 + 12j print("\nType of z: ", type(z))
Let’s run the code
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
Example Boolean data typeprint(type(True)) print(type(False))
Let’s run the code
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
Example of String, List and Tuples#Strings str = "Basic Engineer" print(str) #list list1 = [1, "basic", "engineer", 2] print(type(list1)) #Tuples tup = ("basic", "engineer", 1) print (type(tup)
Let’s run the code
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
0 Comments