Python Data Types
Index
- Type of data for Python
- Python Number
- Python List
- Python Tuple
- Python string
- Python set
- Python Dictionary
- conversion between a data type
Types of data in Python:
Each Python value has a type of data. Because everything is a part of the Python program, the types of data are actually a model of change in the classroom.
Python numbers:
We can use the type () to determine whether the class changes or the value of the property and the work () to ensure that the item has a specific class.
Drivers can be any length, only limited memory.
The top scorer number has 15 decimals. All scores and variables vary by ten points. 1 is the amount, the price estimate is 1.0 points.
The exact number is written in the form, x + y, where x is a real part and is a fractional part.
Below is an example.
a = 5
print(a, "is of type", type(a))
a = 2.0
print(a, "is of type", type(a))
a = 1+2j
print(a, "is complex number?", isinstance(1+2j,complex))
Python List:
The list is an order for an order. This is one of the largest types of data used in Python and is very loose. All substances are not necessarily the same type.
He said a simple and easy list. Sort items are visible in the shoulders []
Below is an example.
a = [5,10,15,20,25,30,35,40]
# a[2] = 15
print("a[2] = ", a[2])
# a[0:3] = [5, 10, 15]
print("a[0:3] = ", a[0:3])
# a[5:] = [30, 35, 40]
print("a[5:] = ", a[5:])
Python Tuple:
The tuple is a series of items similar to the list. The only difference is that the thieves are not able to. Pipes, when done, can not be changed.
Taps are used to record data that is usually faster than the list since they can not change the circumstances.
It is designed to attach () when the products are separated by oil.
Below is an example.
t = (5,'program', 1+3j)
# t[1] = 'program'
print("t[1] = ", t[1])
# t[0:3] = (5, 'program', (1+3j))
print("t[0:3] = ", t[0:3])
# Generates error
# Tuples are immutable
t[0] = 10
Python strings:
The string is a series of Unicode characters. We can use single words or double quotes to represent patterns. A number of lines can be made using a three-dimensional, ' ' ' or " " ".
Below is an example.
s = 'Hello world!'
# s[4] = 'o'
print("s[4] = ", s[4])
# s[6:11] = 'world'
print("s[6:11] = ", s[6:11])
# Generates error
# Strings are immutable in Python
s[5] ='d'
Python is set:
Make a variety of special items. Specific points defined in the stages {}. The set is not continuous.
Python language
Glossaries are an inaccurate organization that is key to key and value.
Usually used when we have a lot of information.
Below is an example.
a = {5,2,3,1,4}
# printing set variable
print("a = ", a)
# data type of variable a
print(type(a))
Python Dictionary:
Dictionaries are targeted for data recovery. We need to know how to get the price.
Python, the glossary defines between any facet of any item that becomes an important partner in the form: value. the cost of the keys and everything that can be written.
Below is an example.
d = {1:'value','key':2}
print(type(d))
print("d[1] = ", d[1]);
print("d['key'] = ", d['key']);
# Generates error
print("d[2] = ", d[2]);
conversion between a data type:
We can change the types of data by changing the type of work to look like int (), float (), Str (), etc.
Check out these examples to learn more:
- Add two number
- Find the square root
- Calculate the area of a triangle
Comments
Post a Comment