Introduction to Variables and Data Types in Python
Variables in Python:
Variables in Python are used to store data values
Variables in Python are fundamental for storing and manipulating data. Unlike other programming languages, Python doesn't require you to declare the type of a variable when you create one. This flexibility is one of the key features of Python, making it easy and intuitive to use.
Naming Rules
1. Variable names must start with a letter(a-z, A-Z) or an underscore(_).
2. The rest of the name can contain letters, digits(0-9), or underscores.
3. Variable names are case-sensitive ('Var' and 'var' are different).
Invalid Variable Names
1. 2Value=10
It cannot Start with a digit
2. First-name="Jane"
Hyphens are not allowed
3. My var=20
Spaces are not allowed
Type Checking and Conversion:
To check the type of a variable, you can use the type() function. Python also provides functions for type conversion.
x = 10
print(type(x))
Conversion
t=float(x)
print(t)
kindly like, share, and subscribe to my channel.