Python - Functions
[Pages:25]Python - Functions
CS101
Computer Science, CMU CS101 Introduction to computer
Motivation
Computer Science, CMU CS101 Introduction to computer
What is a function
(a named sequence of statements) () Example
>>> a = len("Python 3") >>> print(a) >>> 8
We call a function len( ) which takes one argument and returns a result. The result is called the return value.
Computer Science, CMU CS101 Introduction to computer
Why use functions? (1/2)
Abstraction
? ? ? arguments ?
( )
Computer Science, CMU CS101 Introduction to computer
Why use functions? (2/2)
Reusability
Easy maintenance, Readability
Computer Science, CMU CS101 Introduction to computer
Functions in Python
Built-in
Python See a list of the functions next page.
User defined
built-in
Pay attention to!
? Function specification: argument argument
? Return value:
Computer Science, CMU CS101 Introduction to computer
Python built-in functions
Computer Science, CMU CS101 Introduction to computer
Two types of built-in function
General function
len() len() string, list function len(argument)
Object-type specific function
uppercase string int float dot "mystring".upper() MYSTRING
Computer Science, CMU CS101 Introduction to computer
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- python lambda functions tutorial point
- python run functions in parallel
- python list functions in module
- python 3 functions list
- list functions in python 3
- python commands and functions pdf
- python functions cheat sheet pdf
- python calling functions in functions
- python functions with different arguments
- python built in functions list
- functions in python example
- calling python functions from c