Ch 4 · Data Types — Kinds of Values · Python

Topic 4 of 13 in Python — Complete Tutorial (Beginner) — 5 lessons.

What is a Data Type?

Every piece of information stored in a program belongs to a category. A number like 42 is very different from a word like "Alice", even though the computer stores both in memory. Python uses the concept of a data type to keep these categories separate. A data type tells you what kind of value a variable holds — and what you can do with it. You can multiply two numbers, but multiplying two sentences makes no sense.

Numbers: int and float

Python has two main number types. An int is a whole number with no decimal point — your age, a count of students, a score. A float is a number with a decimal point — a price, an average, a measurement. Python automatically picks the right one, and it happily mixes them in calculations. One thing to know: ordinary division with / always produces a float, even when the result is whole. If you want a whole-number result, Python gives you a special "floor division" operator //.

Strings (str)

A string is any sequence of characters — letters, digits, spaces, punctuation, even emojis — wrapped inside quotation marks. Strings hold all the human-readable text in your program: names, sentences, messages, labels. In Python you can use single quotes '...' or double quotes "..." interchangeably. Strings come with many built-in tools called methods that let you transform and inspect text, and you call them with a dot after the string.

Booleans (bool)

A boolean is the simplest data type — it has exactly two possible values: True and False. Note the capital letters: Python is strict about this. Booleans are the language of decisions. Every time your program needs to choose between two paths, it relies on a boolean. When you write an if statement, the condition must evaluate to either True or False.

None and type()

Python has a special value called None that represents "nothing" or "no value yet." It is not zero and it is not an empty string — it is a deliberate way of saying "this is intentionally empty." For example, a winner variable might start as None before a game finishes, then get a real name once someone wins. None is Python's equivalent of "null" in other languages.

All topics in Python Beginner

  1. Introduction to Programming & Python
  2. Your First Python Program
  3. Variables — Your Data Containers
  4. Data Types — Kinds of Values
  5. Operators & Expressions
  6. Conditional Statements
  7. Loops & Iterations
  8. Functions
  9. Lists — Collections of Data
  10. Dictionaries & Classes
  11. Strings — Working with Text
  12. Error Handling
  13. Mini-Projects & Practice