DEV Community

Cover image for Variables in Python
Aswin Barath
Aswin Barath

Posted on • Edited on

3 1 1 1 1

Variables in Python

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
Enter fullscreen mode Exit fullscreen mode

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. Alt Text

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>
...
Enter fullscreen mode Exit fullscreen mode
  • 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>
...
Enter fullscreen mode Exit fullscreen mode

Note

Keep in mind that python is case - sensitive, which means the variable like hello and Hello are very different for python.

Best Resources

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🙂.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay