What are the Data Types Supported in Python Language
Data Types: Python data types is a type of data which is used in the program. There is no need of data type to declare a variable in python. Python data type is a predefined function of python which is used to get data type of any data.
These data types can be used to store different types of data such as numbers, text, and collections of data. Each data type has its own properties and methods that can be used to manipulate the data stored in it.
Learn Best Python Data Types in 2023 |
Types of Data Types|Built in Data Types in Python
1. Integer (int)
2. Float (float)
3. String (str)
4. Boolean (bool)
5. List (list)
6. Tuple (tuple)
7. Set (set)
8. Dictionary (dict)
9. Complex (complex)
Which is not an integer data type
Integer Data Types: A Python integer data type is a main data type used to represent integers is the int class. This class can hold integers of any size, limited only by the amount of memory available. Python also has a long data type, which is used to represent integers of even larger size, but this type has been removed in python3.x version. In python3.x version int type is used for both small and large integers.
Which of the following is smallest integer data type
x=10 y=20 z=x+y print("Value of z:",z) **********OUTPUT********** Value of z:30 |
Float Data Type in Python
Float Data Type: Float data type can be used to represent floating-point numbers (numbers with decimal points) is the float class. This class can hold numbers with decimal places, and can also represent numbers in scientific notation.
Float Data Type Example in Python
x=13.5 y=22.6 z=x+y print("Value of z:",z) **********OUTPUT********** Value of z:36.1 |
String Data Type in Python
String Data Type: String Data Type can be used to represent strings of characters is the str class. A string is a sequence of characters enclosed in single or double quotes.
"Welcome To Learncoding" 'Welcome To Learncoding' "Welcome To Learncoding" |
Python offers many built-in methods for manipulating strings, such as concatenation, slicing, and string formatting. There are also many powerful libraries available for working with strings, such as regular expressions, which can be used for pattern matching and text manipulation.
You can also use triple quotes(''' or """) to create multiline strings in python.
Where is String Data Type Used in Python
name="Welcome To Learncoding" print(name) **********OUTPUT********** Welcome To Learncoding |
What is String Data Type Explain its Use
name='Welcome To Learncoding' print(name) **********OUTPUT********** Welcome To Learncoding |
What is Triple Code String Data Type in Python
name='''Welcome To Learncoding''' print(name) **********OUTPUT********** Welcome To Learncoding |
Boolean Data Type in Python
Boolean Data Type Example
x = 5 y = 10 z = x < y print(z) **********OUTPUT********** True |
List Data Type in Python
List Data Type Example
data = [1, "hello", 3.14, True] print(data[0]) **********OUTPUT********** 1 |
Tuple Data Type in Python
Tuple Data Type Example
data_tuple = (1, "hello", 3.14, True) print(data[2]) **********OUTPUT********** hello |
Set Data Type in Python
Set Data Type Example
a = {1, 2, 3} b = {2, 3, 4} print("Union Set Data Type:",a | b) print("Intersection Set Data Type:",a & b) print("Difference Set Data Type:",a - b) print("Symmetric Difference Set Data Type:",a ^ b) **********OUTPUT********** Union Set Data Type:{1, 2, 3, 4} Intersection Set Data Type:{2, 3} Difference Set Data Type:{1} Symmetric Difference Set Data Type:{1, 4} |
Dictionary Data Type in Python
Dictionary Data Type Example
person = {'name': 'Python', 'age': 30, 'city': 'Noida'} print(person) **********OUTPUT********** {'name': 'Python', 'age': 30, 'city': 'Noida'} |
Complex Data Type in Python
Complex Data Type Example
z1 = 3 + 4j z2 = 2 - 3j print(z1 + z2) print(z1 - z2) print(z1 * z2) print(z1 / z2) **********OUTPUT********** 5 + 1j 1 + 7j -6 + 11j 1.6 - 0.6j |
0 Comments