“Fonctions Python” Réponses codées

comment coder une fonction de python

def hi():
  print("hi!")
  
Curious Cowfish

#Function dans Python

#Function in python

def identity(age):
    print("You are "+str(age)+" Years old")
identity(input("Type your age: "))

def id(name):
    print("Hello "+name+"."+"You are our valued customer")
    print("Have a nice Day "+name)
id(input("Type your name: "))

# if you want to use the input method to get the user info more
# than one time then you should make two function.
# In one function you can't get the multiple results.if anyone can find
# please add to greeper ans.
YEASIN ARAFAT

Définition de la fonction dans Python

# defining a function  
def my_func():  
    print("Greetings User! Welcome to Softhunt.net")  
  
# calling the function  
my_func()
Outrageous Ostrich

fonction Python

#math function in python:
def math(x,y):
    z = x * y
    return z
A = math(7,8)
print(A)
YEASIN ARAFAT

Fonctions Python

def myfunction():{print(5), print(6)}
Bob7012

Fonctions Python

'''
Functions are very useful in python because you can use them instead
of repeating code in your program which makes your code messy.
'''

# This is how you create a function
def functionName():
  print('Hello World!')
  
functionName() # prints out 'Hello World!'
functionName() # prints out 'Hello World!' again

# Functions can have attributes which you insert into the function
def add(a, b):
  print(a + b)
  
add(2, 4) # prints out '6'
add(11, 35) # prints out '46'

# Finally, functions can return values which you can save as variables
def addFive(value):
  return value + 5

myVar = addFive(3) # myVar becomes equal to 8 (3 + 5)
print(myVar) # prints out myVar

'''
Keep in mind that scope comes into play in your functions. If you
create a variable in a function, it won't be saved outside the
function.
'''
def createVar():
	myVar = 5
    
createVar()
print(myVar) # returns error (unless you defined myVar outside function)
Ninja Penguin

Réponses similaires à “Fonctions Python”

Questions similaires à “Fonctions Python”

Plus de réponses similaires à “Fonctions Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code