In Python, the variable type is fixed and cannot be modified once it is declared (in Python it should not be declared, but should be used)
That's right:
1 var = 12print(Var)3 var = 24print(VAR)
Output variable var values, 1 and 2 in turn.
Error:
1 var = 12print(Var)3" I am a variable "4 Print(VAR)
Compile errors, error on the third line.
Data types in Python:
Boolean |
Isclosed=true |
Integer |
Age=18 |
Float |
height=1.70 |
String |
message= "Hello World" or message= ' Hello World ' |
List |
list=[1,2,3,4,5] |
Tuple |
Tuple= (1,2,3,4,5) |
Dict |
dict={' Tom ': ' Lily ': 20} |
Set |
Set=set ([1,2,3,4,5]) |
Note: A tuple is a simplified list that cannot be modified once it is initialized. Set is a collection, and elements cannot be duplicated.
A string in Python.
Declaring a string in Python can be in single or double quotes:
1 ' Hello ' 2 " Hello " 3 Print (VAR==VAR2)
The output is true.
Segmentation of Strings:
1 ' I am tom\n, and you? ' 2 words = var.split ()3print(words)
The output will be
['I'am'Tom', and'you? ' ']
Python By default splits strings by spaces and line breaks
The connection of the string:
1 words = ['I','am','Tom' ]2". Join (words)3print(str)
The output:
I am Tom
Python learns the -5.python of variables and data types and the segmentation and connection of strings