Python Language Functions: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:
   c = a + b
   c = a + b
   return c
   return c
</syntaxhighlight>
=Built-in Functions=
* <span id='type.28.29'></span><code>type()</code> returns the type of the argument.
* <code>print()</code>. If more comma-separated arguments are used, every comma adds a space.
* <code>input()</code> instructs Python to pause and read data from stdin. <code>input()</code> returns a string.
<syntaxhighlight lang='python'>
s = input('this is the prompt')
print(s)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 20:12, 22 May 2021

Internal

Overview

Declaration:

def function_name(arguments):
  <function body>

Invocation:

function_name(arguments)

Example

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

Built-in Functions

  • type() returns the type of the argument.
  • print(). If more comma-separated arguments are used, every comma adds a space.
  • input() instructs Python to pause and read data from stdin. input() returns a string.
s = input('this is the prompt')
print(s)