[python] 난수 생성하기 random의 모든 것
random 모듈을 이용하여 난수 생성하기 module importimport random random.random( )# 0이상 1미만의 실수random.random()→ 0.28483 random.randrange( start , stop [ , step] ) *정수만 생성# 1이상 7미만의 정수random.randrange(1, 7) # 1이상 10미만, 간격 2random.randrange(1, 10, 2)→ [1, 3, 5, 7, 9] 중 하나 random.randint( Start, End )# start 이상 end 이하의 정수 생성random.randint( 1, 3 )→ 1~3 중 하나 random.uniform( a, b ) *실수 생성# 1이상 2이하 실수 생성rand..
2024. 9. 22.
[python] python GUI 모듈 tkinter (Text, Input, RadioButton, Button)
tkinter 모듈로 python GUI 만들기GUI 창 생성, Label 입력, Input 값 가져오기, RadioButton 값 가져오기, Button 생성 1. GUI 창 생성import tkinter as tkroot = tk.Tk()# 타이틀 설정root.title('타이틀')# 크기 설정root.geometry('300x300')# 크기 조절root.resizable(Boolean, Boolean)root.mainloop() 2. 텍스트(Label) 입력하기label1 = tk.Label(root, text="label1")label2 = tk.Label(root, text="label2")label1.pack()label2.pack() 3. input 입력창 만들기entry1 = tk.E..
2024. 9. 21.