python

이번엔 평균 구하기다...... 또 다시 C#을 먼저 말해본다면.. 리스트에 .Sum(), .Average() 함수가 존재하여 호출만 해주면 끝.... C# 너무 편하죠............... 파이썬도 쉽게 사용하기 위한 언어니깐 당연히 편한게 있겠지!!!! 바로 코드 ㄱㄱ import statistics arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] arr2 = [15, 26, 48, 59, 57, 68, 35, 24] # 평균 구하기 result1 = statistics.mean(arr1) result2 = statistics.mean(arr2) # 출력 print(f"average1 : {result1}") print(f"average2 : {result..
프로그램을 개발하다보면.... 특정 모듈이... 특정 함수가.. 시간이 얼마나 걸리는지 체크해야할때가 있다. WPF의 경우 Stopwatch라는 클래스가 따로 존재하여 start, stop함수를 통해 계산했었는데... 파이썬은...어떤함수가 있을지 알아보도록 하자.. 파이썬의 기본 모듈인 time 모듈을 확인하면 시간측정을 할 수 있다 바로 코드 ㄱㄱ import time start = time.time() print("시간측정") print("some function....") end = time.time() print(f"{end - start:.5f} sec") Output: 0.00000 sec 너무 간단한 print문 2개라.. 0.000초가 나온다... 좀 시간이 걸릴만한걸하면... impor..
import sys, os from PyQt5.QtWidgets import * class BaseWindow(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel("EXAMPLE") self.btn_1 = QPushButton("QInputDialog") self.btn_1.clicked.connect(self.Input_showDialog) self.btn_2 = QPushButton("QColorDialog") self.btn_2.clicked.connect(self.Color_showDialog) self.btn_3 = QPushButton("QFontDialog") self..
import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSpinBox, QDoubleSpinBox, QVBoxLayout class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl1 = QLabel('QSpinBox') self.spinbox = QSpinBox() self.spinbox.setMinimum(-10) self.spinbox.setMaximum(30) # self.spinbox.setRange(-10, 30) self.spinbox.setSingleStep(2) self.lbl2 = QLabel('..
import sys from PyQT5.QtWidgets import QApplication, QWidget, QLabel, QDateTimeEdit, QVBoxLayout from PyQT5.QtCore import QDateTime class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel('QTimeEdit') self.lbl2 = QLabel('QTimeEdit') self.datetimeedit = QDateTimeEdit(self) self.datetimeedit.setDateTime(QDateTime.currentDateTime()) self.dateti..
import sys from PyQt5.QtWidgets import QApplication, QWidget, QComboBox, QLabel, QVBoxLayout from PyQt5.QtCore import Qt class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): # 라벨 생성 self.l = QLabel('Option1', self) # 콤보 박스 생성 self.cb = QComboBox(self) # 콤보 아이템 추가 self.cb.addItem('Option1') self.cb.addItem('Option2') self.cb.addItem('Option3') self.cb.addIt..
주지님
'python' 태그의 글 목록 (2 Page)