Code Playground
# Online Python coding environments and visualizers for hands-on practice
🎮 Online Python Compilers
Practice Python programming in your browser with these online coding environments:
👁️ Python Code Visualizers
Visualize how your Python code executes step by step to better understand program flow:
💡 How to Use These Tools
📝 For Coding Practice
- Start with simple programs from your labs
- Experiment with different Python features
- Test your solutions before submitting
- Try debugging your code step by step
👁️ For Code Visualization
- Use visualizers to understand loops and conditionals
- See how variables change during execution
- Debug complex algorithms visually
- Learn how Python handles different data types
🚀 Quick Start Examples by Chapter
Try these Python programs organized by course chapters. Practice examples that match your current learning progress:
Chapter 1: Introduction to Python
# Hello World Program print("Hello, World!") print("Welcome to Python Programming!")
Chapter 2: Elementary Programming
# Variables and Data Types name = "Alice" age = 25 height = 5.6 is_student = True print(f"Name: {name}, Age: {age}, Height: {height}, Student: {is_student}")
# User Input and Output name = input("Enter your name: ") age = int(input("Enter your age: ")) print(f"Hello {name}, you are {age} years old!")
Chapter 3: Mathematical Functions and String
# Mathematical Functions import math number = 16 print(f"Square root: {math.sqrt(number)}") print(f"Power: {math.pow(number, 2)}") print(f"Absolute value: {abs(-number)}")
# String Manipulation text = "Hello Python Programming" print(text.upper()) print(text.lower()) print(text.replace("Python", "Java")) print(len(text))
Chapter 4: Selections
# Simple Conditional Statements number = 10 if number > 5: print("Number is greater than 5") else: print("Number is 5 or less")
# Multiple Conditions with elif score = 85 if score >= 90: print("Grade: A") elif score >= 80: print("Grade: B") elif score >= 70: print("Grade: C") else: print("Grade: F")
# Age Validation with Input age = int(input("Enter your age: ")) if age >= 18: print("You are an adult!") elif age >= 13: print("You are a teenager!") else: print("You are a child!")
# Random Number with Conditions import random number = random.randint(1, 10) print(f"Random number: {number}") if number > 7: print("High number!") elif number > 4: print("Medium number!") else: print("Low number!")
Chapter 5: Loops
# For Loop with Range for i in range(1, 6): print(f"Number: {i}")
# While Loop Counter count = 1 while count <= 5: print(f"Count: {count}") count += 1
# Nested Loops for i in range(1, 4): for j in range(1, 4): print(f"{i} x {j} = {i * j}")
Chapter 6: Functions
# Simple Function with Parameters def greet(name, age): return f"Hello {name}, you are {age} years old!" message = greet("Alice", 25) print(message)
# Calculator Function with Conditions def calculator(a, b, operation): if operation == "+": return a + b elif operation == "-": return a - b elif operation == "*": return a * b elif operation == "/": return a / b else: return "Invalid operation" print(calculator(10, 5, "+"))
# Complete Game with Functions import random def number_guessing_game(): secret_number = random.randint(1, 10) guess = int(input("Guess a number between 1 and 10: ")) if guess == secret_number: print("Congratulations! You guessed it!") else: print(f"Sorry, the number was {secret_number}") number_guessing_game()