1607177357.jpg

What is different Method and Functions in Python ?

Người đăng: Nguyễn Hoàng Anh Ngày đăng: 05-02-2021 285 lượt xem

Content is written by English when I learn

Functions

  • A function is a block of code to carry out a spiciffic task and called by name. All of function has zero (0) argument or more than one arguments. 
  • On exit, a function can or can't return one or more than one values function return.
  • EX: def add(a,b):

return a+b

  • Out: print(add(1,2)) : 3
  • The function allows us to implement code reusability. build-code, User-defined functions, Anonymous function (def lamb2) 
 

Methods

  • A method in python is somewhat similar to a function, except it is associated with object/classes.
  • Methods in python are very similar to functions except for two major differences.

Bài viết liên quan

Bình luận bài viết