Skip to main content

What Are Variables in Python?

When we start learning Python, one of the first concepts we come across is variables. But what exactly are they?

Understanding Variables 

A variable is like a container that stores information. Imagine you have a box, and you put something inside it—like a number, a word, or even a list of items. The name of the box is the variable, and the thing inside is the value. In Python, variables don’t need special declarations. You simply assign a value using the = sign, and Python will take care of the rest

Think of it like this: You have a jar, you put candies inside it and stick a label on the jar called candies. Now, whenever you want to know how many candies you have, you just look at candies.



Key Points About Variables in python

Dynamic Typing: Unlike some other languages, you don't need to specify a variable's type. Python automatically figures it out based on the value you assign to it (e.g., a number, a string, etc.).

A Label, Not a Box: A variable in Python is a label or a name tag that points to a specific value stored in your computer's memory. When you change the variable's value, you're just pointing the label to a new location in memory.

Variable Naming Rules:
  • Names can contain letters, numbers, or underscores (_).
  • They must start with a letter or an underscore.
  • They cannot start with a number.
  • You cannot use any of Python's reserved keywords (like for, if, class, def, while, etc.) as a variable name.

 

Comments

Popular Posts

A beginner's guide to HTTP/1 vs. HTTP/2

HTTP, is a foundational protocol for communication on the World Wide Web. It defines how messages are formatted and transmitted between web clients and web servers, enabling the retrieval of web pages, images, videos, and other resources. Essentially, it's the language that web browsers and servers use to "talk" to each other.  What is HTTP? The Postman Analogy HTTP, or Hyper Text Transfer Protocol , is the fundamental set of rules that allows your web browser and a website's server to "talk" to each other. Think of it like this: You are the person who wants a package.   The Postman is your web browser. The Store is the website’s server (e.g., google.com ). When you want to visit a website, your browser uses HTTP to tell the server what you want. The server then finds the information and sends it back to your browser, which displays it for you. HTTP/1 The first major version of the Hyper Text Transfer Protocol , which is the basic system that web browsers...

From Code to Cloud - Understanding Hosting 🌐

Hosting (or Web Hosting) is a service that allows individuals or organizations to store their website files (HTML, CSS, images, videos, etc.) on a server connected to the internet so that anyone in the world can access the website via a domain name (like www.google.com).  Ever wondered how a website like youtube.com stays online 24/7 for anyone in the world to visit? The answer is hosting . It’s the essential service that makes your website visible on the internet and accessible to everyone, everywhere.  To understand it, let’s use a simple and relatable analogy: building and living in a house. The Landlord, the Land, and the House   Imagine your website is a house you want to build and open for visitors. The Website is the House: Your website is a collection of all its different parts. The front door is your homepage, the rooms are the other pages, and the furniture, decor, and art are all the files that give your site its look and feel. These are files like index....

Top 3 GitHub Features Every Beginner Should Master

Introduction If you’re just starting your journey as a developer, GitHub can feel a bit overwhelming. It’s packed with tools that professionals use every day but which ones should you focus on first? You don’t need to learn everything at once. Instead, start with the features that will give you the biggest benefits right away: safety, organization, and automation. Here are my top 3 GitHub features that every beginner should master and exactly why they matter. 1. Branches & Pull Requests Branches let you create  a copy of your project to try out new changes without ever touching the main, working code. It's like having a clone of your project where you can experiment freely.  Pull Requests   are how you propose merging those new changes back into the main project. They serve as a formal request to "pull" your changes from your branch into the main one, often after a review process. Benefits : You can experiment without fear of "breaking"...