Variables in programming are something like containers storing some specific things.
Variables are a way we store data on the computer.
This is how we create variables in python:
Syntax:
variable_name = data
But, there's a catch here, you cannot have some crazy names as variable names in python.
There are some best practices in python being followed by the python community when it comes to naming your variable names.
Do's
- Variable names can contain letters, numbers, underscore
- Always start with a lowercase letter or an underscore
- snake_case Use lowercase letters and underscores for spaces.
Dont's
- Do not use reserved keywords of python as variable names, coz this is what python will tell you:
...
Traceback (most recent call last):
File "./program.py", line (x), in <module>
...
- Do not use special characters like !,@,#,$,%,^,&,* in a variable name, coz you will get the same error message:
...
Traceback (most recent call last):
File "./program.py", line (x), in <module>
...
Note
Keep in mind that python is case - sensitive, which means the variable like hello and Hello are very different for python.
Best Resources
Python Blog Series : A Blog series where I will be learning and sharing my knowledge on each of the above topics.
Learn Python for Free, Get Hired, and (maybe) Change the World! : A detailed roadmap blog by Jayson Lennon (a Senior Software Engineer) with links to free resources.
Zero To Mastery Course - Complete Python Developer : A comprehensive course by Andrei Neagoie (a Senior Developer) that covers all of the above topics.
Who Am I?
I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath
Thank you so much for reading my blog🙂.
Top comments (0)