Python variables are the allocated memory locations and Datatypes define the type of variable.
Below is a table summarizing some of the basic variables and data types in Python, along with their syntax and examples:
Name | Description | Syntax | Example |
---|---|---|---|
Integer | A whole number | x = 42 | x = 42 |
Float | A decimal number | x = 42.0 | x = 42.0 |
String | A sequence of characters | x = "Hello" | x = "Hello" |
Boolean | A value that is either True or False | x = True | x = True |
List | An ordered collection of values | x = [1, 2, 3] | x = [1, 2, 3] |
Tuple | An ordered, immutable collection of values | x = (1, 2, 3) | x = (1, 2, 3) |
Dictionary | An unordered collection of key-value pairs | x = {"key": "value"} | x = {"name": "John", "age": 30} |
These are some of the basic data types in Python, and you can use them to store values and manipulate data in your programs.
Additionally, there are other data types in Python, such as complex numbers, sets, and more, which you can learn in next tutorial.