Days16_OOP : Object Oriented Programming
Steve Jobs in 1994: The Rolling Stone Interview
Even at one of the low points in his career, Jobs still had confidence in the limitless potential of personal computing
www.rollingstone.com
* 객체 지향 프로그래밍
- 가진것(has) > 속성(attributes)
- 하는것(does) > 메소드(methods)
- 속성과 메서드를 청사진화 > Class
- Class를 통해 만든 Object
----
import another_module
print(another_module.another_variable)
# import turtle
# timmy = turtle.Turtle()
from turtle import Turtle, Screen #turtle:모듈 Turtle:클래스
timmy = Turtle() #timmy:오브젝트
print(timmy)
--> <turtle.Turtle object at 0x000001B8E12853F0> object가 메모리에 저장(print)
* Object Attributes
object | Attribute
ex) car.speed
my_screen = Screen()
print(my_screen.canvheight)
* Object Methods #method : object에 묶인 함수?
object | Method
ex) car.stop()
my_screen.exitonclick()
timmy.shape("turtle") #timmy의 모양을 turtle로 변경
https://docs.python.org/3/library/turtle.html
turtle — Turtle graphics — Python 3.10.2 documentation
turtle — Turtle graphics Source code: Lib/turtle.py Introduction Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon i
docs.python.org
timmy.color("Orange")
my_screen = Screen()
print(my_screen.canvheight)
timmy.forward(100)
import 한 모듈의 class에서 object를 생성
from prettytable import PrettyTable # import class 'PrettyTable' from module 'prettytable'
table = PrettyTable() # crate an object 'table' from class 'PrettyTable()'
table.add_column("Pokemon Name",["Pikachu","Squirtle","Charmander"])
table.add_column("Type",["Eletric","Water","Fire"])
print(table)
print(table.align)
table.align ="r"
print(table)
print(table.align)