is function in python code example

Example 1: create function in python

def myFunction():
  print('I am running in a function!')

Example 2: python function

def name():#name of the def(function);
  print("Hallo, World!")#Output is Hallo, World!;
  
name()#Name of the def, the programm will jump to the def;

#output:
#Hallo, World!

Example 3: python funtion

def nameOfFunction(something):
  	return something

Example 4: function in function python

def function1(): # outer function
    print ("Hello from outer function")
    def function2(): # inner function
        print ("Hello from inner function")
    function2()

function1()

Example 5: functions in python

# Functions

""" All the functions are followed by the 'def' keyword in python"""

def Greet(User): # The arguments inside the brackets should be called or the function gives you an error
  print("Hello" + User + "!")
  
# Calling the function

Greet("Shivram")

# Output: 'Hello Shivram !'

Example 6: python functions

#Functions
def string():
  print('This is a function')
  
  print(string())

Tags:

Misc Example