1. The Python Environment
Welcome to the Python Revision Tour. This section recapitulates the basics of Python, an interpreted high-level language. Explore the two modes of operation provided by IDLE and understand the fundamental building blocks (Tokens) of the language.
Working Modes
Type "copyright", "credits" or "license()" for more information.
>>> print("Hello")
Hello
>>> 10 + 50
60
>>> _
Interactive mode executes commands line-by-line. Great for testing.
Python Tokens
The smallest lexical units in a program.
Reserved words (e.g., if, else, True)
Names for variables, functions
Fixed values (10, "Hello")
Symbols for computation (+, -, *)
2. Variables, Types & Operators
Python uses Dynamic Typing, meaning you don't declare types explicitly. Variables are created when you assign values. Explore how Python handles data and performs operations below.
TRY IT Dynamic Typing Detective
Try: 123, 12.5, "Python", [1,2]
Operator Lab
Inputs
Output Console
3. Control Flow
Control structures guide the execution path of a program. Use the simulators below to visualize Decision Making (if..elif..else) and Iteration (Loops).
Vote Eligibility Checker (if-else)
For Loop Visualizer
print(i)
Note: range(1, 6) excludes the upper limit 6.
4. Data Structures
Organizing data is crucial. Here we explore Strings (Immutable), Lists (Mutable), and Dictionaries. Interact with the tools below to understand slicing and methods.
String Slicing Laboratory
List Operations (Mutable)
Current List: [10, 20, 30]
Dictionary (Key-Value)
Grade Book
5. Functions & Modules
Functions promote reusability. Modules like `random` extend capabilities. Below, visualize how `random.randint()` behaves over many trials.
Random Distribution Visualizer
Click "Generate" to simulate rolling a 6-sided die 100 times using
random.randint(1, 6).
The chart shows the frequency of each number.
counts = [0] * 7
for _ in range(100):
roll = random.randint(1, 6)
counts[roll] += 1