DEV Community

Cover image for Understanding Variables in Python
Ganesh Kumar
Ganesh Kumar

Posted on

Understanding Variables in Python

Hello, I'm Ganesh Kumar, and I'm building LiveReview — a blast-radius aware AI code review built for your business-critical systems. Star us to help devs discover the project, give it a try, and share your feedback to help improve the product.

In the previous post, I explained how to use comments. Now, in this article, I will discuss Python variables.

What Are Python Variables?

In maths, we say a variable is a reference point where we actually store a number for doing some operation. Similarly, in a programming language, a variable is a container (storage area) to hold data. For example,

pyhog = 10
Enter fullscreen mode Exit fullscreen mode

Here, pyhog is a variable storing the value 10.

We assign those values using the assignment operator =.

So, any value we can assign.

Assigning Values to Variables in Python

As we can see from the above example, we use the assignment operator = to assign a value to a variable.

Another example where we are storing normal words:

blog = 'dev.to'

print(blog)

# Output: dev.to
Enter fullscreen mode Exit fullscreen mode

Here, we assigned a value inside '' and we print that value using that variable name.

Python is a type-inferred language, so you don't have to explicitly define the variable type. It automatically knows that dev.to is a string and declares the blog variable as a string.

Changing Variable Value

We can actually update the value accordingly.

blog = 'dev.to'

print(blog)

# Output: dev.to

blog = 3

print(blog)

# Output: 3
Enter fullscreen mode Exit fullscreen mode

As Python handles variables dynamically, it allows us to update an int with a string variable holder.

Rules for Naming Variables

There are a few rules which all developers should follow to have some structured code instead of random words.

Each variable should have its meaning.

For example, if I want to store the score of a team, we will use score but not count.

There are many things we actually define.

Other than these meaningful variable naming conventions, we have these rules:

  1. Constant and variable names should have a combination of letters in lowercase (a to z) or uppercase (A to Z), digits (0 to 9), or an underscore (_).
snake_case
MACRO_CASE
camelCase
CapWords
Enter fullscreen mode Exit fullscreen mode
  1. Create a name that makes sense. For example, score makes more sense than i.

  2. If you want to create a variable name having two words, use an underscore to separate them.

my_name
current_salary
Enter fullscreen mode Exit fullscreen mode
  1. Python is case-sensitive. So, num and Num are different variables. For example,
var score = 3 
var Sum = 90
print(num) # 3
print(Num) # 90
Enter fullscreen mode Exit fullscreen mode
  1. Avoid using keywords like if, True, class, etc. as variable names.

I'm building LiveReview, a blast-radius aware AI code review built for your business-critical systems.

Instead of presenting every diff with equal emphasis, LiveReview scores each change by blast radius — how far its impact reaches through your call graph — so you can focus attention where it actually matters.

Spend code review effort where business risk is highest — not spread evenly across every diff.

⭐ Star it on GitHub:

GitHub logo HexmosTech / LiveReview

Blast-Radius Aware AI Code Review for Business-Critical Systems

LiveReview

gitleaks.yml osv-scanner.yml govulncheck.yml semgrep.yml dependabot-enabled mcp-testcases.yml

LiveReview: Blast-Radius Aware AI Code Review for Business-Critical Systems

LiveReview is an AI code reviewer that scores every hunk of a diff by blast radius: how far a change reaches through your call graph, how much persistent state it touches, and how well-tested it is. A 3-line change to a shared auth check can outrank a 300-line UI tweak. Your team's attention goes to the highest-risk code first, not spread evenly across every diff.

blast-radius-demo.mp4

LiveReview's Blast Radius & Review Priority scoring, live in the diff viewer.
















The exact math, not a black box Visualize blast radius at a glance Every factor that feeds the score

How does Blast Radius scoring work? (a more technical explanation)

Here's the goal:

  • A 3-line fix in a function used by 40 other files, that also writes to a database, should score high.
  • A 300-line UI change in one file, fully covered by…




Click below to try LiveReview with your codebase:

LiveReview Banner

Top comments (0)