PYnative

Practice Coding

  • Python â–¼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Coding Exercises â–¼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • MCQsâ–¼
    • Python MCQ Quizzes
    • Java MCQ Quizzes
    • C++ MCQ Quizzes
  • Compilersâ–¼
    • Online Python Compiler
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » Python » Python Functions

Python Functions

Updated on: November 30, 2026 | 14 Comments

In Python, a function is a named block of code that performs a specific task. Use functions whenever you need to perform the same task several times without writing the same code again. A function can take arguments and return a value.

Functions follow the DRY principle, which stands for Don’t Repeat Yourself. If you need to do the same task many times, you can define that task once in a function and call the function whenever you need it.

Functions improve efficiency and reduce errors because the code is reused. Once you create a function, you can call it anywhere and any number of times. The main benefits of functions are reusability and modularity.

Also, See

  • Python Functions Exercise
  • Python Functions Quiz

Table of contents

  • Types of Functions
  • Creating a Function
    • Creating a function without any parameters
    • Creating a function with parameters
    • Creating a function with parameters and return value
  • Calling a function
    • Calling a function of a module
  • Docstrings
    • Single-Line Docstring
    • Multi-Line Docstring
  • Return Value From a Function
    • Return Multiple Values
  • The pass Statement
  • How does Function work in Python?
  • Scope and Lifetime of Variables
    • Local Variable in function
    • Global Variable in function
      • Global Keyword in Function
    • Nonlocal Variable in Function
  • Python Function Arguments
    • Positional Arguments
    • Keyword Arguments
    • Default Arguments
    • Variable-length Arguments
  • Recursive Function
  • Python Anonymous/Lambda Function
    • filter() function in Python
    • map() function in Python
    • reduce() function in Python
  • Functions are first-class objects
  • Type hints in functions
  • Summary

Types of Functions

Python supports two types of functions:

  1. Built-in function
  2. User-defined function

Built-in function

Functions that come with Python itself are called built-in functions or predefined functions. Some of them are:
range(), id(), type(), input(), len(), print(), etc.

Example: Python range() function generates the immutable sequence of numbers starting from the given start integer to the stop integer.

for i in range(1, 10):
    print(i, end=' ')
# Output 1 2 3 4 5 6 7 8 9Code language: Python (python)

User-defined function

Functions that you write yourself for your own needs are called user-defined functions.

Creating a Function

Use the following steps to define a function in Python.

  • Use the def keyword followed by the function name and parentheses.
  • Inside the parentheses, list the parameters the function needs, if any (optional), and end the line with a colon (:).
  • Write the function body as an indented block of code. This block is the action you want the function to perform.

In Python, you don’t use curly braces for the function body. Instead, the body must be indented under the def line. Wrong indentation causes an IndentationError.

Syntax of creating a function

def function_name(parameter1, parameter2):
    # function body
    # write some action
    return valueCode language: Python (python)

Here,

  • function_name: Function name is the name of the function. We can give any name to function.
  • parameter: Parameter is the value passed to the function. We can pass any number of parameters. Function body uses the parameter’s value to perform an action
  • function_body: The function body is a block of code that performs some task. This block of code is nothing but the action you wanted to accomplish.
  • return value: Return value is the output of the function.

Note: While defining a function, we use two keywords, def (mandatory) and return (optional).

Python Functions
Python Functions

Creating a function without any parameters

Let’s start with a simple function that prints a welcome message.

# function
def message():
    print("Welcome to PYnative")

# call function using its name
message()Code language: Python (python)

Output

Welcome to PYnative

Creating a function with parameters

Let’s create a function that takes two parameters and displays their values.

In this example, we create a function with two parameters, name and course_name.

# function
def course_func(name, course_name):
    print("Hello", name, "Welcome to PYnative")
    print("Your course name is", course_name)

# call function
course_func('John', 'Python')Code language: Python (python)

Output

Hello John Welcome to PYnative
Your course name is Python

Creating a function with parameters and return value

Functions can return a value. The return value is the output of the function. Use the return keyword to return a value from a function.

# function
def calculator(a, b):
    add = a + b
    # return the addition
    return add

# call function
# take return value in variable
res = calculator(20, 5)

print("Addition :", res)
# Output Addition : 25Code language: Python (python)

Calling a function

Once you have defined a function, you can call it by its name. You can also call it from another function, or from another program by importing it.

To call a function, write its name followed by parentheses. If the function accepts parameters, pass the values inside the parentheses.

Example

# function
def even_odd(n):
    # check whether the number is even or odd
    if n % 2 == 0:
        print('Even number')
    else:
        print('Odd Number')

# call the function by its name
even_odd(19)
# Output Odd NumberCode language: Python (python)

Calling a function of a module

Python comes with many built-in modules whose functions you can use in your code. For example, the random module has functions for generating random numbers and data.

Let’s see how to use functions defined in any module.

  • First, we need to use the import statement to import a specific function from a module.
  • Next, we can call that function by its name.
# import randint function
from random import randint

# call randint function to get random number
print(randint(10, 20))
# Output 14Code language: Python (python)

Docstrings

In Python, a documentation string is called a docstring. It is descriptive text (like a comment) that explains what a piece of code does, so other people can understand and use it.

You write a docstring as the very first statement inside a module, class, function, or method.

It is written using triple single quotes (''' ''') or triple double quotes (""" """).

You can read the docstring of any object, such as a list, a dict, or your own function, using its __doc__ attribute, or by passing the object to help().

Single-Line Docstring

A single-line docstring fits on one line. The opening and closing quotes must be the same, and by convention, you should use triple double quotes (""").

def square(x):
    """Return the square of a number."""
    return x * x

# access the docstring
print(square.__doc__)Code language: Python (python)

Output

Return the square of a number.

When you use the help() function to get information about a function, it shows the docstring.

# pass the function to the help() function
help(square)Code language: Python (python)

Output

Help on function square in module __main__:

square(x)
    Return the square of a number.

Multi-Line Docstring

A multi-line docstring starts with a short summary line, followed by a blank line and a more detailed description, such as the function’s arguments and return value.

The general format of writing a multi-line Docstring is as follows:

Example

import inspect

def any_fun(parameter1):
    """
    Description of function.

    Arguments:
        parameter1 (int): Description of parameter1.

    Returns:
        int: Description of the return value.
    """
    return parameter1

# getdoc() returns the docstring with the indentation cleaned up
print(inspect.getdoc(any_fun))Code language: Python (python)

Output

Description of function.

Arguments:
    parameter1 (int): Description of parameter1.

Returns:
    int: Description of the return value.

Return Value From a Function

In Python, the return statement sends a value back from a function. It returns the value of the expression that follows the return keyword.

Syntax of return statement

def fun():
    statement-1
    statement-2
    statement-3
    .          
    .          
    return [expression]Code language: Python (python)

The return value is the result of the function.

  • The return statement ends the function execution.
  • For a function, it is not mandatory to return a value.
  • If a return statement is used without any expression, then the None is returned.
  • The return statement should be inside of the function block.

Example

def is_even(list1):
    even_num = []
    for n in list1:
        if n % 2 == 0:
            even_num.append(n)
    # return a list
    return even_num

# Pass list to the function
even_num = is_even([2, 3, 42, 51, 62, 70, 5, 9])
print("Even numbers are:", even_num)Code language: Python (python)

Output

Even numbers are: [2, 42, 62, 70]

Return Multiple Values

You can also return multiple values from a function. Write them after the return keyword, separated by commas.

Example:

In this example, we return four values from a function and read them into four variables. Python actually packs the values into a single tuple, and the assignment unpacks it.

def arithmetic(num1, num2):
    add = num1 + num2
    sub = num1 - num2
    multiply = num1 * num2
    division = num1 / num2
    # return four values
    return add, sub, multiply, division

# read four return values into four variables
a, b, c, d = arithmetic(10, 2)

print("Addition: ", a)
print("Subtraction: ", b)
print("Multiplication: ", c)
print("Division: ", d)
# Output
# Addition:  12
# Subtraction:  8
# Multiplication:  20
# Division:  5.0Code language: Python (python)

The pass Statement

In Python, pass is a keyword that does nothing. A function body can’t be empty, so when you want to define a function now and write its code later, put pass in the body.

When Python reaches a pass statement, nothing happens. It is a placeholder that keeps the code syntactically valid.

Example

def addition(num1, num2):
    # implementation of the addition function will come in a later release
    pass

addition(10, 2)Code language: Python (python)

How does Function work in Python?

Functions let you write short, clean code that can be reused throughout a program.

Functions help you organize code. A function accepts parameters as input, processes them, and returns a value as output.

When you call a function, Python jumps to the function’s code, runs it with the arguments you passed, and then returns to the line where the function was called, bringing back the return value.

The following diagram shows how the function works.

Scope and Lifetime of Variables

The scope of a variable is the part of the program where it can be accessed. Variables created inside a function have a local scope: they can be used only inside that function.

You can’t access local variables from outside the function, because they are not visible there.

Note: An inner function (a function defined inside another function) can read the variables of the outer function.

Local variables exist only while the function is running. Once the function returns, they are destroyed. So a function doesn’t remember the values of its local variables from a previous call.

The following code shows the scope of a variable inside a function.

Example

global_lang = 'DataScience'

def var_scope_test():
    local_lang = 'Python'
    print(local_lang)

var_scope_test()
# Output 'Python'

# outside of function
print(global_lang)
# Output 'DataScience'

# NameError: name 'local_lang' is not defined
print(local_lang)Code language: Python (python)

In the above example, we print the global variable and the local variable from outside the function. The global variable global_lang is accessible by its name.

But when we try to access the local variable local_lang from outside the function, we get a NameError, because it exists only inside the function.

Local Variable in function

A local variable is declared inside a function and can’t be accessed from outside of it. Its scope is limited to the function where it is declared.

If we try to access the local variable from the outside of the function, we will get the error as NameError.

Example

def function1():
    # local variable
    loc_var = 888
    print("Value is :", loc_var)

def function2():

    print("Value is :", loc_var)

function1()
function2()Code language: Python (python)

Output

Value is : 888
print("Value is :", loc_var) # gives error,
NameError: name 'loc_var' is not defined

Global Variable in function

A global variable is a variable declared outside of any function. It is accessible from all functions in the same module.

Example

global_var = 999

def function1():
    print("Value in 1st function :", global_var)

def function2():
    print("Value in 2nd function :", global_var)

function1()
function2()Code language: Python (python)

Output

Value in 1st function : 999
Value in 2nd function : 999

Global Keyword in Function

A function can read a global variable, but it can’t change it by assignment, because assigning creates a new local variable instead. The global keyword tells Python to use the global variable. We use it for two purposes:

  1. To create a global variable from inside a function.
  2. To change the value of an existing global variable from inside a function.

Let’s see what happens when we assign to a global variable inside a function without the global keyword.

# Global variable
global_var = 5

def function1():
    print("Value in 1st function :", global_var)

def function2():
    # Assigning creates a new local variable
    # the global variable is not changed
    global_var = 555
    print("Value in 2nd function :", global_var)

def function3():
    print("Value in 3rd function :", global_var)

function1()
function2()
function3()Code language: Python (python)

Output

Value in 1st function : 5
Value in 2nd function : 555
Value in 3rd function : 5

As you can see, function2() treated global_var as a new variable (local variable). To solve such issues or access/modify global variables inside a function, we use the global keyword.

Example:

# Global variable
x = 5

# defining 1st function
def function1():
    print("Value in 1st function :", x)

# defining 2nd function
def function2():
    # Modify global variable using global keyword
    global x
    x = 555
    print("Value in 2nd function :", x)

# defining 3rd function
def function3():
    print("Value in 3rd function :", x)

function1()
function2()
function3()Code language: Python (python)

Output

Value in 1st function : 5
Value in 2nd function : 555
Value in 3rd function : 555

Nonlocal Variable in Function

In Python, nonlocal is a keyword used inside an inner function (a function defined inside another function). It tells Python that a variable refers to the variable of the outer function.

Use nonlocal when an inner function needs to change a variable that belongs to the enclosing function, instead of creating a new local variable.

Example 

def outer_func():
    x = 777

    def inner_func():
        # local variable now acts as global variable
        nonlocal x
        x = 700
        print("value of x inside inner function is :", x)

    inner_func()
    print("value of x inside outer function is :", x)

outer_func()Code language: Python (python)

Output

value of x inside inner function is : 700
value of x inside outer function is : 700

Python Function Arguments

An argument is a value, variable, or object that you pass to a function when you call it. Python supports four types of arguments:

  1. Positional arguments
  2. keyword arguments
  3. Default arguments
  4. Variable-length arguments

Read the complete guide on Python function arguments.

Positional Arguments

Positional arguments are passed to a function in the correct positional order: the 1st argument goes to the 1st parameter, the 2nd argument to the 2nd parameter, and so on. In the example below, the function subtracts its second argument from its first, so swapping them changes the result.

Example

def add(a, b):
    print(a - b)

add(50, 10)
# Output 40
add(10, 50)
# Output -40Code language: Python (python)

If you pass more arguments than the function accepts, you get an error.

def add(a, b):
    print(a - b)

add(105, 561, 4)Code language: Python (python)

Output

TypeError: add() takes 2 positional arguments but 3 were given

With positional arguments, both the number and the order of the arguments matter. If you change the order, the result may change. If you pass the wrong number of arguments, you get an error.

Keyword Arguments

A keyword argument is a value passed to a function together with the parameter name and an equals sign, for example, name="John".

Example

def message(name, surname):
    print("Hello", name, surname)

message(name="John", surname="Wilson")
message(surname="Ault", name="Kelly")
Code language: Python (python)

Output

Hello John Wilson
Hello Kelly Ault

With keyword arguments, the order doesn’t matter, but every required parameter must still receive a value. Otherwise, you get an error.

When you mix positional and keyword arguments, the positional arguments must come first, followed by the keyword arguments. Otherwise, you get a SyntaxError, as the following example shows.

Example

def message(first_nm, last_nm):
    print("Hello..!", first_nm, last_nm)

# correct use
message("John", "Wilson")
message("John", last_nm="Wilson")

# Error
# SyntaxError: positional argument follows keyword argument
message(first_nm="John", "Wilson")
Code language: Python (python)

Default Arguments

A default argument takes a default value when you don’t pass it in the function call. You assign the default value in the function definition using the = operator.

For example, a function show_employee(name, salary=9000) accepts an employee’s name and salary. If the salary is missing from the function call, the function automatically uses the default value 9000.

 Example

# function with default argument
def message(name="Guest"):
    print("Hello", name)

# calling function with argument
message("John")

# calling function without argument
message()Code language: Python (python)

Output

Hello John
Hello Guest

When you pass an argument, the function uses that value. When you leave it out, the function uses the default value. Parameters with default values must come after parameters without them.

Warning: don’t use a mutable default value

A default value is created only once, when the function is defined, not every time it is called. If the default is a mutable object such as a list, changes to it are kept between calls. Use None as the default and create a new list inside the function instead.

# wrong: the same list is reused
def add_item(item, items=[]):
    items.append(item)
    return items

print(add_item(1))  # [1]
print(add_item(2))  # [1, 2]  (surprise!)

# right: create a new list on each call
def add_item(item, items=None):
    if items is None:
        items = []
    items.append(item)
    return items

print(add_item(1))  # [1]
print(add_item(2))  # [2]Code language: Python (python)

Variable-length Arguments

Sometimes you don’t know in advance how many arguments a function will receive. Such arguments are called variable-length arguments. Declare one by putting an asterisk (*) before the parameter name.

def fun(*var):
    function bodyCode language: Python (python)

You can pass any number of arguments to this function. Inside the function, all of them are collected into a tuple. By convention, this parameter is usually named *args.

Example

def addition(*numbers):
    total = 0
    for no in numbers:
        total = total + no
    print("Sum is:", total)


# 0 arguments
addition()

# 5 arguments
addition(10, 5, 2, 5, 4)


# 3 arguments
addition(78, 7, 2.5)Code language: Python (python)

Output

Sum is: 0
Sum is: 26
Sum is: 87.5

Variable-length keyword arguments (**kwargs)

To accept any number of keyword arguments, put two asterisks (**) before a parameter name. Inside the function, those arguments are available as a dictionary.

def info(**kwargs):
    for key, value in kwargs.items():
        print(key, ":", value)

info(name="Jessa", age=28)Code language: Python (python)

Output

name : Jessa
age : 28

Read more: The complete guide on Python function arguments.

Recursive Function

A recursive function is a function that calls itself.

For example, calculating the factorial of a number is a repetitive task: the factorial of 5 is 5 times the factorial of 4, and so on. So a function can call itself with a smaller number each time until it reaches 0.

factorial(5)
    
5*factorial(4)
5*4*factorial(3)
5*4*3*factorial(2)
5*4*3*2*factorial(1)
5*4*3*2*1 = 120

Example

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

print("factorial of a number is:", factorial(8))
Code language: Python (python)

Output

factorial of a number is: 40320

The advantages of recursive functions are:

  1. Recursion can make code shorter.
  2. It can make code easier to read for problems that are naturally recursive.
  3. It is useful for breaking a complex problem into smaller sub-problems, such as working with trees or nested data.

The disadvantages of recursive functions are:

  1. Recursive functions usually use more memory and run slower than an equivalent loop, because each call is stored on the call stack.
  2. Recursive functions can be harder to debug.
  3. Python limits the recursion depth (1000 calls by default). Going deeper raises a RecursionError, so every recursive function needs a base case that stops the recursion, like if no == 0 above.

Python Anonymous/Lambda Function

Sometimes you need a small function without a name. A function without a name is called an anonymous function or lambda function.

Anonymous functions are handy for short, one-time operations. A normal function is defined with the def keyword, while an anonymous function is created with the lambda keyword.

Unlike a normal function, a lambda function body is a single expression, not a block of statements. For example, lambda n: n + n returns double its argument.

Syntax of lambda function:

lambda arguments: expressionCode language: Python (python)

A lambda function can take any number of arguments, but it contains only one expression, and it returns the value of that expression. For example, add = lambda x, y: x + y creates a function, and add(2, 3) returns 5.

Let’s print the even numbers from a list, first without a lambda function and then with one. Compare the number of lines and the readability of the code.

Example 1: Program for even numbers without lambda function

def even_numbers(nums):
    even_list = []
    for n in nums:
        if n % 2 == 0:
            even_list.append(n)
    return even_list

num_list = [10, 5, 12, 78, 6, 1, 7, 9]
ans = even_numbers(num_list)
print("Even numbers are:", ans)Code language: Python (python)

Output

Even numbers are: [10, 12, 78, 6]

Example 2: Program for even number with a lambda function

l = [10, 5, 12, 78, 6, 1, 7, 9]
even_nos = list(filter(lambda x: x % 2 == 0, l))
print("Even numbers are: ", even_nos)Code language: Python (python)

Output

Even numbers are: [10, 12, 78, 6]

You don’t write a return statement in a lambda function. The value of the expression is returned automatically.

Lambda functions are most useful when you need to pass a short function as an argument to another function, for example, to built-in functions such as filter(), map(), sorted(), and functools.reduce().

filter() function in Python

In Python, the filter() function keeps only the items of a sequence for which a given function returns True. Use it to select values based on a condition.

Syntax of filter() function:

filter(function, sequence)Code language: Python (python)

where,

  • function – a function that returns True for the items to keep
  • sequence – any iterable, such as a list, tuple, or string

Example: lambda function with  filter()

l = [-10, 5, 12, -78, 6, -1, -7, 9]
positive_nos = list(filter(lambda x: x > 0, l))
print("Positive numbers are: ", positive_nos)Code language: Python (python)

Output

Positive numbers are: [5, 12, 6, 9]

map() function in Python

In Python, the map() function applies a function to every item of a sequence and returns the results as a new iterable (an object you can loop over or convert to a list).

Ex: for every element present in the sequence, perform cube operation and generate a new cube list.

Syntax of map() function:

map(function,sequence)Code language: Python (python)

where,

  • function – the function to apply to each item of the sequence
  • sequence – any iterable, such as a list, tuple, or string

Example: lambda function with map() function

list1 = [2, 3, 4, 8, 9]
list2 = list(map(lambda x: x*x*x, list1))
print("Cube values are:", list2)Code language: Python (python)

Output

Cube values are: [8, 27, 64, 512, 729]

reduce() function in Python

In Python, the reduce() function combines the items of a sequence into a single value. It applies a two-argument function to the first two items, then to that result and the next item, and so on.

The reduce() function is present in the functools module; hence, we need to import it using the import statement before using it.

Syntax of reduce() function:

reduce(function, sequence)Code language: Python (python)

Example: lambda function with reduce()

from functools import reduce
list1 = [20, 13, 4, 8, 9]
add = reduce(lambda x, y: x + y, list1)
print("Addition of all list elements is : ", add)Code language: Python (python)

Output

Addition of all list elements is : 54

Functions are first-class objects

In Python, a function is an object like any other value. You can assign it to a variable, store it in a list, pass it as an argument to another function, and return it from a function. That’s exactly why filter(), map(), and reduce() can accept a function as their first argument.

def shout(text):
    return text.upper() + "!"

def apply(func, value):
    # call the function that was passed in
    return func(value)

print(apply(shout, "hi"))
# Output HI!Code language: Python (python)

Type hints in functions

You can add optional type hints to show what type each parameter should be and what the function returns. Python doesn’t enforce them at runtime, but they make code easier to read, and editors and tools such as mypy use them to catch mistakes.

def area(length: float, width: float) -> float:
    return length * width

print(area(2.5, 4))
# Output 10.0Code language: Python (python)

Summary

  • A function is a named, reusable block of code. Define it with def, and call it by its name followed by parentheses.
  • Use return to send a result back. Without it, a function returns None. Return several values separated by commas, and Python packs them into a tuple.
  • Document functions with docstrings, and read them with help() or __doc__.
  • Variables created inside a function are local. Use global or nonlocal only when you really need to change an outer variable.
  • Arguments can be positional, keyword, default, *args, or **kwargs. Never use a mutable object as a default value.
  • Recursive functions call themselves and need a base case. Lambda functions are small anonymous functions, often used with filter(), map(), reduce(), and sorted().

Next Steps

  • Python Functions Exercise
  • Python Functions Quiz

Filed Under: Python, Python Basics

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises
Java Exercises
C# Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes
In: Python Python Basics
TweetF  sharein  shareP  Pin

  Python Tutorials

  • Get Started with Python
  • Python Statements
  • Python Comments
  • Python Keywords
  • Python Variables
  • Python Operators
  • Python Data Types
  • Python Casting
  • Python Control Flow statements
  • Python For Loop
  • Python While Loop
  • Python Break and Continue
  • Python Nested Loops
  • Python Input and Output
  • Python range function
  • Check user input is String or Number
  • Accept List as a input from user
  • Python Numbers
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python Functions
  • Python Modules
  • Python isinstance()
  • Python OOP
  • Python Inheritance
  • Python Exceptions
  • Python Exercise for Beginners
  • Python Quiz for Beginners

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

  • Python Basics
  • Python Exercises
  • Python Quizzes
  • Python File Handling
  • Python Date and Time
  • Python OOP
  • Python Random
  • Python Regex
  • Python Pandas
  • Python Databases
  • Python MySQL
  • Python PostgreSQL
  • Python SQLite
  • Python JSON

About PYnative

PYnative.com is a platform built to help developers learn by doing. Solve coding exercises, take MCQs, and run code directly in built-in online compilers.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises
  • Java Exercises
  • C# Exercises

MCQ Quizzes

  • Python MCQs
  • Java MCQs
  • C++ MCQs

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com