본문 바로가기

Language/Python12

[Python] Method Overriding / Operator Overloading / Polymophism Computational Thinking : 일상생활의 문제를 컴퓨터의 이론적인 기술을 활용하여 해결할 수 있는 사고력 OOP : 일상생활의 문제를 사람의 시각에서 사물을 바라보는 관점으로 프로그램을 설계하고자 하는 개념 Method Overriding 상위 Class의 메소드를 하위 Class에서 재정의하는 것. 자식클래스에서 내부적으로 재정의. class Car: speed=0 def upSpeed(self, value): self.speed += value class Sedan(Car): seatNum = 0 def upSpeed(self, value): #재정의 self.speed += value if self.speed>150: self.speed = 150 class Truck(Car): pa.. 2019. 8. 16.
[Python] Object Oriented Programming Object Oriented Programming [중요 POINT] Object Oriented Programming, Class, Object(instance), Inheritance, Method Overriding, Operator Overloading ,Polymorphism - object(객체) : 물체, 사물, 대상 - 객체지향 : 변수 + 함수 객체를 생성해주는 Data Type - Class (user defined data type) Method = 클래스 내 선언 함수 - C-struct struct car{ char color[10]; int speed; }; main(){ struct car mycar1; } upSpeed(){} downSpeed(){} - Python - Cl.. 2019. 8. 14.
0710 Python 문법, 우분투 사용법 - pwd : 현재경로 - ls : 하늘색=디렉토리, 현재 경로 파일 - mkdir test: 새로운 test폴더 만들기 - cd (change direction) test: test dir로 들어가기, cd : 홈디렉토리 - ctrl + d : 터미널쉘 빠져나오기 - 파일실행 : python test.py - jupyternotebook 주석 입력시 # 이 늘어나면 하위 제목이 된다. - * : bullet print("I eat %d apples." % 3) print("I eat %d apples." % 3) number = 10 day = "three" print("i ate %d apples, so %s days" % (number, day)) - 주석처리 ctrl+/ ''' ''' 로 - le.. 2019. 7. 10.
[Python] Except / File [Python] Except / FileExcept - except 12345678910111213141516171819#-*- coding: utf-8 -*-'''''' try: num1 = input("젯수 입력:") num2 = input("피젯수 입력:") print num2,"를", num1, "으로 나눈값:", num2/num1except ZeroDivisionError as zde: print "어떤수를 0으로 나눌수는 없습니다.", zdeexcept Exception as e: print "알수 없는 에러 발생!", eelse: print "오류없이 수행되었습니다."finally: print "오류발생과 상관없이 반드시 실행이 보장되는 블럭입니다." print "프로그램을 마무리 합니다.".. 2017. 8. 17.