PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

Python Variables

← All stacks

Theory

13/268

Python Variables

A variable is a name pointing at a value. age = 21 creates the name age and binds it to 21. No type word on the left. The type lives on the object. Later age = "twenty" is allowed — dynamic typing — but jumping types in real code confuses readers.

Names: letters, digits, underscore. Cannot start with a digit. Cannot be a keyword. Style is snake_case: student_name. a, b = 1, 2 unpacks two values. Using a name before assignment → NameError. That is the first crash most freshers see.

Python Variables — output — Pune · age 21. Two real variables.

Exam tip

Assignment creates the binding; types live on objects.

Example

# Variables
age = 21
city = "Pune"
print(city, "· age", age)

Python Variables — output: Pune · age 21. Two real variables.

Short notes

  • Defname = value.
  • Rulesnake_case. No keyword names.
  • TrapNameError if used before assign.

Questions

1

Explain Variables as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with Variables?

Previous← Python CommentsNextData Types in Python →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.