Variables and Data Types

Variables in Python are used to store values so that we can use them later in a program. They act like containers that hold information such as numbers, text, or other data.

What are Data Types?

Data types define what kind of data is stored in a variable, such as:

  • Integer (int) → Whole numbers
  • String (str) → Text or words
  • Float (float) → Decimal numbers

Real-Life Analogy

Think of variables like labeled boxes.

  • A box labeled Fruits stores fruits.
  • A box labeled Books stores books.

Similarly, Python variables store different kinds of data so the computer can understand and use them correctly.

Check your knowledge

Quickly verify what you've learned from this tutorial.

Question 1

What is a variable in Python?

Variables are used to store information or values in Python.

Question 2

Which data type stores text or words?

String (str) is used to store text in Python.

Question 3

What is the output of this code?
x = 10
print(x)

print() displays the value stored in the variable x.

Question 4

Which of the following is a float data type?

Float data types store decimal numbers.

Question 5

Why do we use data types in Python?

Data types define whether a variable stores numbers, text, or other values.

Congratulations!

You've successfully mastered the knowledge check for "Variables and Data Types."

For more questions and practice, click the link below:

Practice More Questions
Previous Topic Comments in Python Next Topic Variables in Python