Interactive Code Snippets

Code examples for - Page 2

Run, edit, and experiment with ready-to-use code algorithms and utilities right in your browser.

Showing 24 templates
python

Count Characters in a Python String with count()

Learn how to count characters in a Python string using count(). See runnable examples, optional start/end arguments, and time complexity. Try it now!

Run
python

Python String replace(): Replace Characters in a String

Learn how to replace characters in a Python string with replace(), including syntax, examples, and complexity. Try it now!

Run
python

Convert a String to a List in Python Using split() – Examples

Learn how to convert a string to a list in Python with split(). See clear examples for whitespace, delimiters, and maxsplit. Try it now!

Run
python

Python strip() vs lstrip() vs rstrip(): Key Differences Explained

Learn how Python's strip(), lstrip(), and rstrip() differ, with runnable examples. Master whitespace and character trimming today!

Run
python

How to Reverse a String in Python: 3 Easy Methods with Code

Learn how to reverse a string in Python using slicing, reversed(), and loops. Run the code and master string reversal today!

Run
python

Python split() Method Explained with Examples

Master Python's split() method with clear examples. Learn separators, maxsplit, whitespace handling, and outputs. Try it today!

Run
python

Bubble Sort Algorithm in Python: Code, Example & Complexity

Learn Bubble Sort in Python with a runnable example, clear explanation, and complexity analysis. Start coding today!

Run
python

Python Medical EHR System with GUI and Data Structures

A medical records management system with Tkinter GUI, using linked lists, BST, hash tables, and graphs.

Run
python

Convert English Numbers to Persian in Python

Python code to convert English digits to Persian digits in strings and numbers using a dictionary and function.

Run
python

Calculate Compound Interest (FV) with Python

Learn to compute future value of monthly investments with compound interest in Python. Simple formula and example.

Run
python

Python Leap Year Check

Learn how to detect leap years in Python with the is_leap_year function using divisibility rules by 4, 100 and 400, plus code caveats.

Run
python

Simple Python Calculator Code: Full Tutorial & Guide

Build a simple Python calculator with add, subtract, multiply and divide. Learn while loops, input validation and try/except error handling.

Run
python

Convert Gregorian to Jalali Date in Python: Code Review

Analyze a flawed Python snippet that tries to convert Gregorian dates to Jalali and learn the correct approach with jdatetime.

Run
PHP

Understanding intval() in PHP: Converting Data Types to Integer

Learn how PHP's intval() function converts different data types such as floats, strings, and arrays into integers with simple code examples.

Run
python

Generate Secure Random Passwords in Python

Learn how to create strong random passwords with Python's secrets module, ensuring minimum digits and special characters.

Run
PHP

Solve N-Queens Problem in PHP with Backtracking

PHP code to solve the N-Queens puzzle using backtracking, displays all board solutions.

Run
python

Sort Dictionary in Python | Complete Guide

Learn to sort dictionaries by keys and values in Python, including reverse sorting. Code example included.

Run
python

How to Get Integer Part of a Number in Python

Learn two ways to extract the integer part from a float in Python: int() and math.floor(). Understand their differences for negative numbers.

Run
python

Round Numbers to 2 Decimal Places in Python (3 Ways)

Learn 3 simple ways to display a number with two decimal places in Python: round(), string format, and f-string.

Run
python

Python Sum 1 to 100: How to Use sum() and range()

Learn to calculate the sum of numbers from 1 to 100 in Python with sum(range(1, 101)). Includes code explanation and output.

Run
python

Find All Character Positions in a String with Python

Learn how to find all positions of a specific character in a string using Python's find() method in a loop. Simple code example.

Run
python

Extract File Extension in Python Using rindex

Learn how to get file extension from filename in Python using rindex method. Simple and efficient code example.

Run
python

Convert Text to List by Lines in Python

Learn how to use Python's splitlines() method to break a string into a list of lines. Ideal for text file processing and multiline data.

Run
python

Python rfind() Method: Find Last Occurrence of Substring

Learn how to use Python's rfind() method to find the last occurrence of a substring. Example included.

Run