3-1-4-1. Introduction

Functions are useful chunks of code that allow you to encapsulate a task.

Encapsulation is a way to carry out a whole series of steps with one simple command.

For example, imagine you want to bake a cake.

You would need to buy the ingredients,

mix them together in a certain way for specific amounts of time,

put it all in the oven, and then let it cool.

In computer programming, functions

encapsulate all the steps of a process into one command.

In this case, we might just have

a bake cake function and throw all of these directions into this one function.

Now any, time you want to bake a cake,

we just use this function without worrying about all the specifics.

Functions are also used to help organize and optimize code. Let’s get started.

함수에 대한 이 강의에 오신 것을 환영합니다.

이전에는 Python의 여러 내장 함수를 사용했습니다.

여기에서 우리는 우리 자신의 함수를 작성할 것입니다.

함수는 작업을 캡슐화할 수 있는 유용한 코드 덩어리입니다.

캡슐화는 하나의 간단한 명령으로 일련의 전체 단계를 수행하는 방법입니다.

예를 들어 케이크를 굽고 싶다고 상상해보십시오.

재료를 사야하고,

특정 시간 동안 특정 방식으로 함께 혼합하고,

오븐에 모두 넣은 다음 식히십시오.

컴퓨터 프로그래밍에서 함수

프로세스의 모든 단계를 하나의 명령으로 캡슐화합니다.

이 경우에는

케이크를 굽고 이 모든 방향을 이 하나의 함수에 던집니다.

이제 언제든지 케이크를 굽고 싶을 때,

우리는 모든 세부 사항에 대해 걱정하지 않고 이 기능을 사용합니다.

함수는 코드를 구성하고 최적화하는 데에도 사용됩니다. 시작하자.

Functions

Welcome to this lesson on Functions! You’ll learn about:

  • Defining Functions
  • Variable Scope
  • Documentation
  • Lambda Expressions
  • Iterators and Generators

You can think about functions as a way to take what you have already learned how to do, and put it in a holder that allows you to use it over and over again in an easy to use container.

%d