w1coding.comAll tutorials

Python Control

Python lessons
  1. Environment Setup
  2. Introduction
  3. Control
  4. Control
  5. Loops
  6. Functions
  7. Lists
  8. Dictionary
  9. Classes
  10. Exception
  11. File
  12. Libray
  13. Date
  14. Regula
  15. JSON
  16. Web
  17. Zweb
  18. Apis
  19. Unity
  20. Llampda
  21. Iterators
  22. Generators
  23. Files
  24. Context
  25. Ilogging
  26. Multithreading
  27. Networking
  28. SQLite

Python Variables and Data Types

Variables store data values. Python supports multiple data types such as integers, strings, lists, and dictionaries.

Creating Variables

You can create variables simply by assigning values to them:

      
        name = "Alice"
        age = 25
        is_student = True
      
    

Data Types

Python has various built-in data types, including:

  • int: Integer (e.g., 5, -3)
  • float: Decimal number (e.g., 3.14)
  • str: String (e.g., "Hello, World!")
  • bool: Boolean (e.g., True, False)
  • list: Ordered collection (e.g., [1, 2, 3])
  • dict: Dictionary (e.g., {'key': 'value'})

Activity

Try It Yourself!

Create variables for your favorite color, number, and whether you are a student, and print them out.

Quick Quiz

Quick Quiz

  1. What is a variable in Python?
  2. What are the basic data types in Python?

Answers: A variable stores a value. The basic data types are int, float, str, bool, list, and dict.