Study from Python Hour3: Functions

Study from Python Hour3: Functions

Learning materials

Past posts

environment

The function that came out this time

Function naming convention

How to use the function

Try using the function: sorted

Create an original function

def function name (argument 1, argument 2):

Processing

Processing

Return Return value

Function notes

Function: Check arguments and return values

Return value

def my_function1(a):
	print('in function1:'+ str(a))
	
def my_function2(b):
	print('in function1:'+ str(b))
	return

def my_function3(c):
	print('in function1:'+ str(c))
	return 1
	
def my_function4(d):
	print('in function1:'+ str(d))
	return 'aaa'

aa = my_function1(5)
print (aa)

bb = my_function1(10)
print (bb)

cc = my_function1(15)
print (cc)

dd = my_function1(20)
print (dd)
	

>test11_myFunction2.py
in function1:5
None                                <<<Return value without return
in function2:10
None                                <<<Return value of return with no arguments
in function3:15
1                                   <<<return value of return 1
in function4:20
aaa                                 <<< return 'aaa'Return value of


argument

  def my_function(arg1, arg2, arg3):
  	print(str(arg1)+str(arg2)+str(arg3))
  	aa = arg1 * arg2 * arg3
  	print(aa)
  	return
  
  my_function(2, 3, 4)
  
  my_function(arg2=2, arg1=3, arg3=4)
  

How to use the help function

About namespaces and function types

Try using built-in functions

  a = range(5)
  b = range(2, 5)
  
  print(a)
  print(list(a))
  
  print(b)
  print(list(b))
  
  
  for i in range(4, 7):
  	print(i)

This summary

For Quotations / Lightning Talk

Recommended Posts

Study from Python Hour3: Functions
Study from Python Hour4: Object-oriented ②
Study from Python Hour4: Object-oriented ①
Study from Python Hour2: Control statements
Study from Python Hour7: How to use classes
Study from Python Reading and writing Hour9 files
Study from the beginning of Python Hour1: Hello World
Python functions
Study from the beginning of Python Hour8: Using packages
Python study note_002
Python study notes _000
Python study notes_006
sql from python
MeCab from Python
Python study note_003
Python study notes _005
#Python basics (functions)
[Beginner] Python functions
Use C ++ functions from python with pybind11
Python Easy-to-use functions
Python basics: functions
Python study notes_001
Python study day 1
Study from Python Hour6: Frequently used data types: tuple type, set type, dictionary type
Python Beginner's Guide (Functions)
Use thingsspeak from python
Python basic course (12 functions)
Touch MySQL from Python 3
Operate Filemaker from Python
Use fluentd from python
Changes from Python 2 to Python 3.0
Python from or import
Use MySQL from Python
[Python] Memo about functions
Run python from excel
Install python from source
Execute command from Python
Operate neutron from Python!
Use MySQL from Python
Operate LXC from Python
# 4 [python] Basics of functions
Manipulate riak from python
Force Python from Fortran
Python built-in functions ~ Zip ~
Use BigQuery from python.
Execute command from python
Wrap Python built-in functions
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
Curry arbitrary functions with Python ....
Call C language functions from Python to exchange multidimensional arrays
Deep Python learned from DEAP
Python> lambda> tiny functions / callback functions
Getting Started with Python Functions
Python3 programming functions personal summary
Grammar features added from Python3.6
Cheating from PHP to Python
OCR from PDF in Python
Study Python with Google Colaboratory
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)