About 24,100 results
Open links in new tab
  1. Python example scripts
    Beginner Python scripts covering syntax, data structures, functions, modules, and common programming tasks
  2. Python Examples - Programiz

    93+ Python Programming Exampl…

    Learn Python basics with 100 useful examples for beginners, intermediate and advanced learners. …

    codingem.com
    Python Programs - GeeksforGeeks

    These Python code examples cover a wide range of basic concepts in the Python language, …

    GeeksForGeeks
  1. Python is a versatile programming language used for various applications. Here are some basic examples to get you started.

    Hello World Program

    The simplest program in Python is printing "Hello, World!".

    print("Hello, World!")
    Copied!

    Adding Two Numbers

    You can add two numbers using the + operator.

    a = 5
    b = 3
    sum = a + b
    print("Sum:", sum)
    Copied!

    Factorial of a Number

    Calculate the factorial of a number using recursion.

    def factorial(n):
    if n == 0:
    return 1
    else:
    return n * factorial(n-1)

    print(factorial(5)) # Output: 120
    Copied!

    Checking Prime Number

    Check if a number is prime.

    def is_prime(num):
    if num <= 1:
    return False
    for i in range(2, int(num**0.5) + 1):
    if num % i == 0:
    return False
    return True

    print(is_prime(11)) # Output: True
    Copied!

    Fibonacci Sequence

    Generate Fibonacci sequence up to n terms.

    def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
    print(a, end=" ")
    a, b = b, a + b

    fibonacci(10) # Output: 0 1 1 2 3 5 8 13 21 34
    Copied!
    Feedback
  2. Python Examples - W3Schools

    Learn Python syntax, variables, numbers, strings, operators, lists, tuples, sets, dictionaries, functions, classes, modules, dates, JSON, RegEx, PIP, file handling, MySQL, MongoDB and more with code …

  3. 93+ Python Programming Examples - codingem.com

      1. Print ‘Hello World!’ in the Console. The simplest and probably the most common …
      2. Ask User Their Name and Greet Them. To ask for user input in Python, use the …
      3. Create a List of Names in Python. To create a list in Python, add comma …
      4. Merge Two Lists. Given two or more lists in Python, you may want to merge …
      5. Loop Through a List of Names and Print Each. A powerful feature of Python …
  4. Python Programs - GeeksforGeeks

    Sep 25, 2025 · These Python code examples cover a wide range of basic concepts in the Python language, including List, Strings, Dictionary, Tuple, sets, and many …

  5. Top 35 Python Programs and Examples – PYnative

    Apr 22, 2025 · This article offers a hands-on approach to understanding Python by presenting a variety of simple programs and examples. From basic arithmetic operations to fundamental control flow …

  6. Python Examples

    Learn Python programming language with well detailed examples and programs. Cover basics, advanced concepts, and most used Python modules and libraries.

  7. Python Programming Examples - Tutorial Gateway

    Apr 28, 2025 · All these Python programs are explained with multiple examples, and we also did the code analysis. Please visit the Python tutorial to learn …

  8. Python Code Example Handbook – Sample Script Coding ...

    Apr 27, 2021 · Learn Python syntax and coding with lots of code examples for beginners. This handbook covers variables, data types, operators, conditionals, …

  9. 1000+ Python Programming Examples | Sanfoundry

    Explore 1000+ Python programming examples with output and detailed explanations. Learn Python basics to advanced concepts with free programs at Sanfoundry.

  10. Python Code Examples: Practical Coding Snippets

    Apr 19, 2025 · Learn Python programming with this comprehensive list of code examples, sorted by different concepts. Find examples of basic, advanced, and …

By using this site you agree to the use of cookies for analytics, personalized content, and ads.Learn more about third party cookies|Microsoft Privacy Policy