본문 바로가기

전체 글141

19. Python Module 1. Module To create a module in Python, simply write your code in a file with the .py extension. Modules can contain not only functions but also variables, classes, and more. You can import them into other scripts using the import statement. 2. How to use modules using Google Drive 2024. 3. 20.
19. 파이썬 모듈 1. 모듈 파이썬에서 모듈을 만들려면 간단히 .py 확장자를 가진 파일에 코드를 작성하면 됩니다. 모듈은 단순한 함수 뿐만 아니라 변수, 클래스 등도 포함할 수 있으며, 다른 스크립트에서 import 구문을 사용하여 가져올 수 있습니다. 2. 구글 드라이브 활용한 모듈 사용법 2024. 3. 20.
18. Python Error Handling 1. Exception An exception is an unexpected problem or error that can occur during program execution. When an exception occurs, the program is interrupted. Therefore, it is important to handle exceptions appropriately to prevent program interruption and provide error information to the user. 2. Basic Structure of Exception Handling User can handle all exceptions without specifying an error code a.. 2024. 3. 19.
18. 파이썬의 예외처리& 주민번호 유효성 과제 1. 예외 예외(Exception)는 프로그램 실행 중 발생할 수 있는 예상치 못한 문제 또는 오류 상황을 의미합니다. 예외가 발생하면 프로그램은 중단되기 때문에 이를 적절하게 처리하여 중단을 방지하거나 오류에 대한 정보를 사용자에게 제공해야 합니다. 2. 예외 처리 기본 구조 'except' 뒤에 오류 코드를 넣지 않아도 예외 처리가 작동합니다. 3. Exception 클래스 Exception 클래스는 파이썬의 내장 예외 계층 구조에서 거의 모든 내장 예외의 기본 클래스입니다. 이 클래스는 사용자 정의 예외를 만들거나 특정 예외 유형을 잡기 위한 기본적인 인터페이스를 제공합니다. 4. 사용자 정의 예외 클래스를 직접 만들고 활용하기 ※. 과제1: 주민등록번호 유효성 검사 프로그램을 만들어보자 0 0 1.. 2024. 3. 19.
17. Special Method 1. Special Methods Special methods, also known as magic methods in Python, are methods that have names starting and ending with double underscores (__). These methods are automatically called by the Python interpreter when certain operators or built-in functions are used. init : This method is called when an object is created. It is used to initialize the object's attributes. str : This method i.. 2024. 3. 19.
17. 스페셜 메소드 1. 스페셜 메서드 파이썬의 스페셜 메서드 (또는 매직 메서드라고도 불림)는 더블 언더스코어(__)로 시작하고 끝나는 메서드 이름을 갖습니다. 이 메서드들은 특정 구문이나 내장 함수를 사용할 때 파이썬 인터프리터에 의해 자동으로 호출됩니다. init : 객체 생성 시 호출되는 메서드. 객체의 초기 속성을 설정하는 역할을 합니다 str : 객체를 문자열로 표현하는 메서드. print() 함수나 str() 함수 사용 시 호출됩니다 add: + 연산자를 사용할 때 호출되는 메서드. 두 객체의 합을 계산합니다. len: len() 함수 사용 시 호출되는 메서드. 객체의 길이를 반환합니다. getitem: 인덱싱 연산 사용 시 호출되는 메서드. 객체의 특정 인덱스에 위치한 요소를 반환합니다 call: 객체를 함수.. 2024. 3. 19.