Saturday, 31 October 2026

Python Variables Explained in Easy Hindi

 

Python Variables Explained in Easy Hindi and English – Complete Beginner's Guide

Meta Description: Learn Python variables in easy Hindi and English with practical examples, data types, naming rules, common mistakes and practice questions for beginners.

Focus Keyword: Python Variables

Related Keywords: Python variables for beginners, Python variable examples, Python data types, how to declare variables in Python.


Introduction: What Are Variables in Python?

Python is one of the most popular programming languages for beginners. It is used in web development, artificial intelligence, data science, automation and many other fields.

If you are learning Python programming, one of the first concepts you should understand is Variables.

A variable is a name used to store or refer to a value in a Python program.

Think of a variable as a labelled box. You put some information inside the box and use its label whenever you need that information.

For example:

student_name = "Rahul"
student_age = 15
student_marks = 85

In this example:

  • student_name stores a student's name.

  • student_age stores the student's age.

  • student_marks stores the student's marks.

These are called variables.

1. How to Create Variables in Python?

Python does not require a special command to declare a variable.

You can create a variable simply by assigning a value using the equal sign (=).

Syntax:

variable_name = value

Example:

name = "Priya"
age = 20
city = "Ropar"

print(name)
print(age)
print(city)

Output:

Priya
20
Ropar

Here, the print() function displays the values stored in the variables.

2. Types of Values Stored in Python Variables

Python variables can refer to different types of values.

A. Integer (int)

An integer is a whole number without a decimal point.

Example:

age = 25
students = 40

print(age)
print(students)

B. Float (float)

A float is a number that contains a decimal point.

Example:

price = 99.50
percentage = 85.75

print(price)
print(percentage)

C. String (str)

A string is a collection of characters written inside quotation marks.

Example:

student_name = "Anjali"
subject = "Computer Science"

print(student_name)
print(subject)

D. Boolean (bool)

Boolean values represent either True or False.

Example:

is_passed = True
is_absent = False

print(is_passed)
print(is_absent)

3. Rules for Naming Variables in Python

Python has some important rules for naming variables.

  1. A variable name must begin with a letter or an underscore.

  2. A variable name cannot begin with a number.

  3. Variable names can contain letters, numbers and underscores.

  4. Spaces are not allowed in variable names.

  5. Python variable names are case-sensitive.

  6. Reserved Python keywords cannot be used as variable names.

Valid Variable Names:

student_name = "Aman"
age2 = 18
_marks = 90
total_marks = 450

Invalid Variable Names:

2age = 18
student name = "Aman"
class = 10

The above examples are invalid because they break Python naming rules.

4. Understanding Case Sensitivity

Python is a case-sensitive programming language.

It means that uppercase and lowercase letters are treated differently.

Example:

name = "Riya"
Name = "Priya"
NAME = "Anjali"

print(name)
print(Name)
print(NAME)

Output:

Riya
Priya
Anjali

All three variables are different.

5. How to Change the Value of a Variable?

You can assign a new value to an existing variable.

Example:

marks = 60

print(marks)

marks = 90

print(marks)

Output:

60
90

The second assignment gives the variable a new value.

6. How to Check the Data Type of a Variable?

Python provides a built-in function called type().

It helps you identify the data type of a value.

Example:

name = "Rahul"
age = 18
percentage = 88.5
passed = True

print(type(name))
print(type(age))
print(type(percentage))
print(type(passed))

Output:

<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>

This is useful when checking values in a Python program.

7. Multiple Variable Assignment

Python allows you to assign values to multiple variables in one statement.

Example:

name, age, city = "Ravi", 20, "Chandigarh"

print(name)
print(age)
print(city)

Output:

Ravi
20
Chandigarh

You can also assign the same value to multiple variables.

a = b = c = 10

print(a, b, c)

Output:

10 10 10

8. Common Mistakes Beginners Should Avoid

Many beginners make small mistakes while creating Python variables.

Here are some common mistakes:

Mistake 1: Using spaces in variable names

Incorrect:

student name = "Riya"

Correct:

student_name = "Riya"

Mistake 2: Starting a variable name with a number

Incorrect:

1student = "Aman"

Correct:

student1 = "Aman"

Mistake 3: Using a variable before assigning a value

Incorrect:

print(age)
age = 20

Correct:

age = 20
print(age)

Mistake 4: Confusing = and ==

  • = is used for assignment.

  • == is used to compare two values.

Example:

age = 18

print(age == 18)

Output:

True

9. Practical Python Program Using Variables

Let's create a simple student information program.

student_name = "Aarav"
student_class = 10
computer_marks = 92
english_marks = 85

total_marks = computer_marks + english_marks

print("Student Name:", student_name)
print("Class:", student_class)
print("Computer Marks:", computer_marks)
print("English Marks:", english_marks)
print("Total Marks:", total_marks)

Output:

Student Name: Aarav
Class: 10
Computer Marks: 92
English Marks: 85
Total Marks: 177

This practical example shows how variables can store and process student information.

10. Practice Questions for Beginners

Test your understanding with these questions.

Q1. Which symbol is used to assign a value to a variable in Python?

A. ==
B. =
C. !=
D. +

Correct Answer: B. =

Q2. Which of the following is a valid variable name?

A. 2marks
B. student name
C. student_marks
D. class

Correct Answer: C. student_marks

Q3. What is the data type of 25.5?

A. int
B. str
C. float
D. bool

Correct Answer: C. float

Q4. Is Python case-sensitive?

A. Yes
B. No

Correct Answer: A. Yes

Q5. Which function is used to check the data type of a variable?

A. print()
B. input()
C. type()
D. sum()

Correct Answer: C. type()

Frequently Asked Questions (FAQs)

1. What is a variable in Python?

A variable is a name that refers to a value or object in a Python program.

2. How do you declare a variable in Python?

You create a variable by assigning a value using the equal sign.

Example: age = 20

3. Can a Python variable store text?

Yes. Python variables can refer to text values called strings.

Example: name = "Rahul"

4. What is the difference between int and float?

An int represents a whole number, whereas a float represents a decimal number.

5. Can we change the value of a Python variable?

Yes. You can assign a new value to an existing variable.

6. What is the use of the type() function?

The type() function identifies the type of an object.

Conclusion

Python variables are one of the most important building blocks of programming. They help programmers store, access and work with information.

By understanding variables, data types, naming rules and practical examples, beginners can build a strong foundation in Python programming.

The best way to learn Python is to practise small programs regularly. Start with simple variables and gradually move towards operators, conditional statements, loops and functions.

Keep Learning, Keep Practising and Keep Coding!


About This Tutorial: This educational article is written for students and beginners who want to understand Python programming through simple explanations and practical examples.

Official Learning Resource: Python Official Documentation

Suggested Next Lesson: Python Data Types Explained with Examples.