studyplan

파이썬 랜덤 공부 본문

카테고리 없음

파이썬 랜덤 공부

무한머니 2022. 3. 15. 20:56

 

from random import*

# print(random()) # 0.0 ~ 1.0 미만의 임의의 값 생성
# print(random()*10) # 0.0 ~ 10.0 미만의 임의의 값 생성

# int 는 정수로 만들어줌 / 소수점자리 없애줌

# print(int(random()*10)) # 0 ~ 10 미만의 임의의 값
# print(int(random()*10)) # 0 ~ 10 미만의 임의의 값
# print(int(random()*10)) # 0 ~ 10 미만의 임의의 값
# print(int(random()*10)) # 0 ~ 10 미만의 임의의 값
 
# 앞의 숫자 를 1로 만들고 싶으면  + 1 을 하면된다

# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값
# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값


# 로또 번호  예시 1번

# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값
# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값
# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값
# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값
# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값
# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값


# 로또번호 예시 2 번

# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값
# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값
# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값
# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값
# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값
# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값


# 로또번호 예시 3번

print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
print(randint(1,45)) # 1 ~ 45 이하의 임의의 값
 
 
오늘의 랜덤공부 
# print(random()) # 0.0 ~ 1.0 미만의 임의의 값 생성

# print(random()*10) # 0.0 ~ 10.0 미만의 임의의 값 생성

 

# print(int(random()*10)) # 0 ~ 10 미만의 임의의 값

 

# print(int(random()*10) + 1 ) # 1 ~ 10 이하의 임의의 값

# print(int(random()*45) + 1 ) # 1 ~ 45 이하의 임의의 값

# print(randrange(1,46)) # 1 ~ 46 미만의 임의의 값

 

print(randint(1,45)) # 1 ~ 45 이하의 임의의 값

 

 

 

 

 

Comments