본문 바로가기

전체 글139

12. User-Defined Function 1. User-Defined Functions It is functions that you create yourself to perform specific tasks. Python has many built-in functions, but sometimes you need to create a function that behaves exactly as you need it to. This is where user-defined functions come in. 1-1. Functions with no parameters and no return value The simplest form of a function It performs a specific task and the result is printe.. 2024. 3. 15.
12. 사용자 정의 함수 1. 사용자 정의 함수 사용자 정의 함수란 사용자가 특정 작업을 수행하기 위해 직접 작성한 함수를 의미합니다. 파이썬에는 많은 내장 함수들이 있지만, 때로는 우리의 요구사항에 맞게 동작하는 함수를 직접 만들어야 할 때가 있습니다. 이때 사용자 정의 함수를 작성하게 됩니다. 기본적인 구조는 아래와 같습니다. 1-1. 매개변수와 반환값이 없는 함수 가장 간단한 형태의 함수입니다. 특정 작업을 수행하고, 결과는 화면에 출력하거나 다른 변수에 저장하는 방식으로 활용됩니다. 1-2. 매개변수가 있고 반환 값이 없는 함수 함수 실행 시 필요한 데이터를 매개변수로 받아 처리하는 함수입니다. 1-3. 반환 값이 있는 함수 함수 실행 결과를 값으로 반환하는 함수입니다. 1-4. 기본값이 설정된 매개변수 매개변수에 기본값.. 2024. 3. 15.
11. Collections and Loops 1. List and For loops: A loop is a control structure used to execute the same task repeatedly. The most commonly used loops are the for loop and the while loop, each suited for different situations. 2. Dictionaries and For loops 3. Comprehensions Comprehension is one of the simple ways to create or transform collections such as lists, sets, and dictionaries in Python. Comprehension is a techniqu.. 2024. 3. 15.
11. 컬렉션과 반복문 1. 리스트와 for문 반복문은 동일한 작업을 여러 번 실행하기 위해 사용되는 제어 구조입니다. 주로 for 문과 while 문이 사용되며, 각각의 반복문은 다른 상황에 적합한 방식으로 사용됩니다. 2. 딕셔너리와 for문 3. 컴프리헨션(Comprehension) 컴프리헨션(Comprehension)은 파이썬에서 리스트, 세트, 딕셔너리 등의 컬렉션을 간단하게 생성하거나 변형하는 방법 중 하나입니다. 컴프리헨션은 반복문과 조건문을 사용하여 간결하게 컬렉션을 생성하는 기법으로, 코드를 더 간단하고 가독성 좋게 작성할 수 있도록 도와줍니다. 3-1. 리스트 컴프리헨션 기존 리스트의 요소를 조건에 따라 필터링하거나 변환하여 새로운 리스트를 간결하게 생성합니다. 데이터 처리 작업의 효율성을 높이고 코드의 간결.. 2024. 3. 15.
10. Loop Statement in Python 1. Loop Statement Loops are control structures used to execute the same task multiple times. They are mainly implemented using for loops and while loops, each suitable for different situations. For Statement: A for loop is suitable when the number of iterations is known in advance. While Statement: Executes code repeatedly while a condition is true. 2. While Statement A while loop is a control s.. 2024. 3. 14.
10. 제어문 - 반복문 1. 반복문 반복문은 동일한 작업을 여러 번 실행하기 위해 사용되는 제어 구조입니다. 주로 for 문과 while 문이 사용되며, 각각의 반복문은 다른 상황에 적합한 방식으로 사용됩니다. for 문: 반복 횟수를 미리 알고 있는 경우에 적합합니다. while 문: 조건이 참인 동안 반복적으로 코드를 실행합니다. 2. while 문 while 문은 특정 조건이 참인 동안 반복적으로 코드 블록을 실행하는 제어 구조입니다. while 문은 주어진 조건이 참인 동안 반복적으로 코드를 실행하며, 조건이 거짓이 되면 반복을 멈춥니다. 3. for문 for 문은 시퀀스(리스트, 튜플, 문자열 등)의 각 항목에 대해 반복 작업을 수행하는 반복문입니다. for 문은 주로 "지정된 범위 내에서 반복"할 때 사용됩니다. 이.. 2024. 3. 14.