파이썬 #야구2 파이썬(QT)야구게임 만들기 예제 from PyQt5 import uic from PyQt5.QtWidgets import * from random import random import sys form_class = uic.loadUiType("myqt08.ui")[0] class WindowClass(QMainWindow, form_class): def __init__(self): super().__init__() self.ranC() self.setupUi(self) self.pb.clicked.connect(self.myclick) self.le.returnPressed.connect(self.myclick) def getS(self,com,mine): ret = 0 c1 = com[0:1] c2 = com[1:2] c3 = com.. 2023. 6. 29. 파이썬 야구게임 예제 번호 맞추기 from random import random def getS(com, mine): ret = 0 c1 = com[0:1] c2 = com[1:2] c3 = com[2:3] m1 = mine[0:1] m2 = mine[1:2] m3 = mine[2:3] if c1== m1 : ret += 1 if c2== m2 : ret += 1 if c3== m3 : ret += 1 return ret def getB(com, mine): ret = 0 c1 = com[0:1] c2 = com[1:2] c3 = com[2:3] m1 = mine[0:1] m2 = mine[1:2] m3 = mine[2:3] if c2==m1 or c3==m1 : ret += 1 if c1==m2 or c3==m2 : ret.. 2023. 6. 27. 이전 1 다음