“Функции Python” Ответ

Как кодировать функцию в Python

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

#Function в 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

Определение функции в Python

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

Функция Python

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

Функции Python

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

Функции 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

Ответы похожие на “Функции Python”

Вопросы похожие на “Функции Python”

Больше похожих ответов на “Функции Python” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования