전체 글 474

[python] 백준 2480 주사위 세개

www.acmicpc.net/problem/2480 2480번: 주사위 세개 1에서부터 6까지의 눈을 가진 3개의 주사위를 던져서 다음과 같은 규칙에 따라 상금을 받는 게임이 있다. 같은 눈이 3개가 나오면 10,000원+(같은 눈)*1,000원의 상금을 받게 된다. 같은 눈이 2개만 www.acmicpc.net def same2(x,y): if x==y: return 1000+x*100 a,b,c=map(int,input().split()) if a==b and b==c: print(10000+a*1000) elif a==b or a==c or b==c: if same2(a,b)!=None:print(same2(a,b)) if same2(b,c)!=None:print(same2(b,c)) if same..

[python] 백준 1251 단어 나누기

www.acmicpc.net/problem/1251 1251번: 단어 나누기 알파벳 소문자로 이루어진 단어를 가지고 아래와 같은 과정을 해 보려고 한다. 먼저 단어에서 임의의 두 부분을 골라서 단어를 쪼갠다. 즉, 주어진 단어를 세 개의 더 작은 단어로 나누는 것이다 www.acmicpc.net www.acmicpc.net/problem/2993 2993번: 세 부분 첫째 줄에 원섭이가 고른 단어가 주어진다. 고른 단어는 알파벳 소문자로 이루어져 있고, 길이는 3보다 크거나 같고, 50보다 작거나 같다. www.acmicpc.net 백준 1251,2993 코드 동일 word = input() n=len(word) group = [[]] for i in range(1,n-1): for j in range(..

파이썬 - 객체 지향, 클래스 개념

객체지향 - 멤버변수와 멤버함수(동작)로 구성됨. 객체들 사이에서 상호작용 추상적인개념(클래스)에 현실적인 대응역할 해주는 것이 인스턴스. 인스턴스는 클래스로부터 만들어지는 각각의 개별적인 객체. 서로 다른 속성값(서로 다른 생성자)가질 수 있음. 클래스 정의 방법 class Cat : #속성, 행위 작성 pass nabi = Cat def __init__(self, name, color="흰색'): # 생성자 함수 : self = 자기참조, name,color을 매개로 전달 nabi, nero 객체생성 출력시 자동으로 문자열로 변환되어 출력됨(포매팅 출력도 포함) 언더바 두개로 변수를 보호할 수 있음 = 캡슐화 클래스이 상속이란- 해당하는 틀에서 다른 클래스를 만드는 것. 이때 본(틀)이 되는 것을 라..

11주차과제) spyder 과제

(1) push 버튼 누르면 창꺼지면서 print출력 # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import QCoreApplication class Window(QWidget): def __init__(self): super().__init__() self.setGeometry(800,250,300,170) self.setWindowTitle("QPushButton") self.UI() def UI(self): self.text=QLabel("Don't Push the button", self) enterPush=QPushButton("Push",self) self.text.move(100, 50)..

파이썬 pyQT예제 모음 (Button, Combobox, Checkbox...)

Button.py # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import * class Window(QWidget): def __init__(self): super().__init__() self.setGeometry(150,250,350,350) self.setWindowTitle("using Button") self.UI() def UI(self): self.text=QLabel("Test", self) enterButton=QPushButton("Enter",self) exitButton=QPushButton("Exit",self) self.text.move(120, 50) enterButton.move(100,80) exitButton.mo..