1. 어떤 클래스의 인스턴스인지 확인하기isinstance(인스턴스, 클래스)해당 인스턴스가 해당 클래스를 기반으로 만들어졌으면 True 상관없는 인스턴스와 클래스인경우 False 리턴 단순 인스턴스를 확인하는 경우 아래와 같이 사용할 수도 있다. type(인스턴스) == 클래스 2. 특이한 이름의 함수이름영어설명eqequal같다nenot equal다르다gtgreat than크다gegreather than or equal크거나 같다ltless than작다le less then or equal작거나 같다 3. 클래스 변수와 메서드 - 클래스 변수 만들기class 클래스이름: 클래스 변수 = 값 - 클래스 변수에 접근하기클래스이름.변수이름 - 클래스 함수 만들기class 클래스이름: @class..
1. 객체 만들기 1) 객체만들기 students = [ { "name":"홍길동", "korean": 87, "math": 80 }, { "name":"김길동", "korean": 50, "math": 80 }, { "name":"이길동", "korean": 14, "math": 54 }, ]print("이름","총점","평균",sep="\t")for student in students: score_sum = student["korean"] + student["math"] score_avg = score_sum/2 print(student["name"], score_sum, score_avg, sep="\t") 2) 딕셔너리를 만들..
1. 모듈 만들기import test_module as testradius = test.number_input()print(test.get_circumference(radius)) (1) __name__ == "__main__"1) ..
1. 외부모듈- 모듈 설치하는 방법 : cmd창을 열어 명령어 실행pip install 모듈이름 (1) Beautiful Soup 모듈- 날씨 가져오기form urlib import requestfrom bs4 import beautifulSouptarget = request.urlopen("http://www.kma.go.kr/weather/forecast/mid-therm-rss3.jsp?stnId=108")soup = BeatifulSoup(target, "html.parser")for location in soup.select("location"): pront("도시: ", location.select_one("city").string)여러개를 선택 할 때에는 select(), 하나만 선택 ..
1. 모듈 (1) 표준모듈 : 기본적으로 내장 (2) 외부 모듈 : 다른 사람들이 만들어 공개한 모듈 사용방법 import 모듈이름 2. 내부모듈 1) math모듈 #math모듈 import math math.sin(1) #사인 math.cos(1) #코사인 math.tan(1) #탄젠트 math.floor(5.4) #내림 math.ceil(4.1) #올림 - 반올림은 round() 사용 2) form구문 from math import sin, cos, tan, floor, ceil sin(1) cos(1) 전부 import 하지 않고 일부만 import하는 방법 3) as 구문 import math as m m.sin(1) m.cos(1) 모듈의 이름을 재정의하여 사용하고싶을 때 4) random 모듈..
1. 오류의 종류 - 구문 오류 : 실행전에 발생하는 오류 - 런타임 오류 : 프로그램 실행 중에 발생하는 오류 2. 예외처리 - 조건문으로 예외처리하기 user_input_a = input("정수입력>>>") if user_input_a.isdigit(): number_input_a = int(user_input_a) print(number_input_a) print(2*3.14*number_input_a) else: print("정수를 입력하지 않았습니다") - try except 구문 사용 try: number_input_a = int(input("정수입력>>>")) print(number_input_a) print(2*3.14*number_input_a) except: print("오류발생") -..