O GoConqr está de visual novo! Conte para nós o que você achou.

Notas

functions in python

Sandeep Sunny Inglês 2 páginas

Conteúdo das notas (2)

Página 1

"functions in python"

A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

Creating a Function:

-------------------------------

In Python a function is defined using the def keyword:

Example:

def my_function():

print("Hello from a function")

Calling a Function:

----------------------------

example:

def my_function():

print("Hello from a function")

my_function()

output:

Hello from a function

Parameters:

-----------------

Information can be passed to functions as parameter.

Parameters are specified after the function name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.

The following example has a function with one parameter (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:

def my_function(fname):

print(fname + " Refsnes")

my_function("Emil")

my_function("Tobias")

my_function("Linus")

output:

-----------

Emil Refsnes

Tobias Refsnes

Linus Refsnes

Página 2

Informações

Descrição
Notas sobre functions in python, criado por Sandeep Sunny em 05-08-2019.
Criado por
Sandeep Sunny · ago 2019
Atualizado
5 ago 2019
Visualizações
4
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?