DEV Community

Cover image for Understanding Literals in Python
Ganesh Kumar
Ganesh Kumar

Posted on

Understanding Literals 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 variables. Now, in this article, I will discuss Python literals.

What Are Python Literals?

Literals are nothing but the right side of the = operator.

That means they are nothing but values which we are going to store in a variable.

blog = 'dev.to'
Enter fullscreen mode Exit fullscreen mode

Here, blog is a variable and dev.to is a literal.

Different Types of Literals

There are different types of literals in Python. Here are some of the commonly used types.

Numeric Literals

Numerical literals are immutable. That means we can't replace the value, but we can only assign different literals.

This deals with 3 types of numerical values.

  1. Integer Literals

Integer literals are numbers without decimal parts. They also consist of negative and positive numbers, which means they are integers in terms of maths:)

For example, 5, -11, 0, 12, etc.

  1. Floating-Point Literals

Floating-point literals are numbers that contain decimal parts.

Just like integers, floating-point numbers can also be both positive and negative. For example, 2.5, 6.76, 0.0, -9.45, etc.

  1. Complex Literals

Complex literals are numbers that represent complex numbers.

Here, numerals are in the form a + bj, where a is real and b is imaginary. For example, 6+9j, 2+3j.

String Literals

So, in the assignment of a string, any text written inside "" will be considered as a string literal. Even text inside '' is also considered a string.

name = "string"
print(name)
name = 'String'
print(name)
Enter fullscreen mode Exit fullscreen mode
string
String
Enter fullscreen mode Exit fullscreen mode

Character Literals

Similar to strings, character literals also contain the same text written inside ''.

name = 's'
print(name)
Enter fullscreen mode Exit fullscreen mode

Boolean Literals

This deals with storing boolean values, i.e., True and False.

Status = True
print(Status)
Enter fullscreen mode Exit fullscreen mode

Special Literals

result = None

print(result)
Enter fullscreen mode Exit fullscreen mode

We use it to assign null variables.

Collection Literals

This is storing literals in a collection.

# list literal
bike = ["BMW", "Kawasaki", "R15"] 
print(bike)

# tuple literal 
numbers = (1, 2, 3) 
print(numbers)

# dictionary literal
alphabets = {'a':'apple', 'b':'ball', 'c':'cat'} 
print(alphabets)

# set literal
vowels = {'a', 'e', 'i', 'o', 'u'} 
print(vowels)
Enter fullscreen mode Exit fullscreen mode

Wrapping Up

Understand the meaning of literals and their use cases. Now, next, we can understand type conversion.
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)