Answers for "python function"

58

python functions

def myFunction(say): #you can add variables to the function
  print(say)

myFunction("Hello")

age = input("How old are you?")

myFunction("You are {} years old!".format(age))

#this is what you get:

Hello
How old are you?
>>11 #lol my real age actually
You are 11 years old!
Posted by: Guest on February-18-2020
2

python function

def my_function():
  print("Hello from a function")


  my_function()
Posted by: Guest on May-12-2021
9

python function

def function():
  print('This is a basic function')
  
function()
// Returns 'This is a basic function'

def add(numA, numB):
  print(numA+numB)
  
add(1,2)
// Returns 3

def define(value):
  return value

example = define('Lorem ipsum')
print(example)
// Returns 'Lorem ipsum'
Posted by: Guest on June-09-2020
4

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!
Posted by: Guest on February-03-2021
0

python function

# Defines Function
def my_function():
  print("Hello")
  print("Bye")

# Calls Function
my_function()
Posted by: Guest on February-23-2021
0

python function

# specify the type of arguments and it expected return type
#(int, str, list...)
# tis wil make the code easyer to read

def foo(value:int) -> None:
	print(value)

foo() # run foo

def foo2(value:str) -> str:
	value += "Hello "
	print(value)
	return value

value_of_foo2 = foo2() # run the function and put its return value in a var
Posted by: Guest on August-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language