Python Language Functions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 11: Line 11:
function_name(arguments)
function_name(arguments)
</syntaxhighlight>
</syntaxhighlight>
=Function Names=
=Function Name Rules=
The convention for function names is the same as for variable names.
The function name rules for function names is the same as for [[Python_Language#Variable_Naming_Rules|variable names]].


=Example=
=Example=

Revision as of 04:58, 26 May 2021

Internal

Overview

Declaration:

def function_name(arguments):
  <function body>

Invocation:

function_name(arguments)

Function Name Rules

The function name rules for function names is the same as for variable names.

Example

def something(a, b):
  c = a + b
  return c

Built-in Functions

type()

type() returns the type of the argument.

print()

print(). If more comma-separated arguments are used, every comma adds a space.

input()

input() instructs Python to pause and read data from stdin. input() returns a string.

s = input('this is the prompt')
print(s)