Functions in Python: Difference between revisions

From Computer Science Wiki
(Created page with " <syntaxhighlight lang="python" line="1" > def welcome(name): if name == "Alisher": likes_hamburgers ="yes" else: likes_hamburgers="no" return l...")
 
No edit summary
Line 1: Line 1:
==Introduction==


In programming, a named section of a program that performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.
Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks. <ref>http://www.webopedia.com/TERM/F/function.html</ref>




Line 15: Line 19:
print welcome("foo")
print welcome("foo")
</syntaxhighlight>
</syntaxhighlight>
==references==
<references />

Revision as of 11:13, 2 March 2016

Introduction

In programming, a named section of a program that performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

Most programming languages come with a prewritten set of functions that are kept in a library. You can also write your own functions to perform specialized tasks. [1]


def welcome(name):
    if name == "Alisher":
        likes_hamburgers ="yes"
    else:
        likes_hamburgers="no"
    return likes_hamburgers
    
print welcome("Bill")
print welcome("Alisher")    
print welcome("foo")

references