###단축키

import   모듈 호출
math.radians(<각도) 각도  라디안 각도를 변환한다
math.ceil(숫자)   숫자 올림
math.floor(숫자)   숫자 내림
math.pi   3.141592653589793
import 모듈명 as 이름 ...은 모듈을 넣어주고 쓸 이름 정한다 모듈이름을 짧게 만들어준다
form 모듈명 import  사용할모듈   모듈중 호출한거 사용한다
import sys   시작 입력갑 받아오기
from random import ... random, uniform, randrange, choice, choies, sample, shuffle

함수오 값을 가져오기위한 모듈명지정

from datetime import ... datetime, timezone, timedelta 시간 정보 모듈
now.strftime(fmt).format(*"년월일시분초")   시간 정보를 나타냄
__name__    
     

### import

import math

print("math.radians(90) - {0}".format(math.radians(90)))

print("math.ceil(3.2) = {0}"/format(math.ceil(3.2)))

print("math.floor(3.2) = {0}".format(math.floor(3.2)))

print("math.pi = {0}".format(maht.pi))

//math.radian(90) = 1.5707963267948966
//math.ceil(3.2) = 4

### form  ~ import ~

 from math import *
 form math import radians, ceil, floor, pi
 
 print("radians(90) = {0}".format(radians(90)))
 
 print("ceil(3.2) = {0}".format(ceil(3.2)))
 print("floor(3.2) = {0}".format(floor(3.2)))
 
 print("pi = {0}".format(pi))
 

###import  sys

import sys

print("sys.argv => {0} {1}".format(type(sys.argv), sys.argv))

for i, val in enumerate(sys.argv):
	print("sys.argv[{0}] => {1}".format(i,val))

###import random

forma random import random, uniform, randrange, choice, choices, sample, shuffle

print("random() => {0}".format(random()))

print("uniform({0}, {1}) =>{2}".format(1.0, 10.0, unifrom(1.0, 10.0)))
start,stop, step = 1, 45, 2
print("randrange({0}, {1}) => {2}".format(start, stop, randrange(start, stop)))
print("randrange({0}, {1}, {2}) => {3}".format(start, stop, step, randrange(start, stop, step))) //범위 랜덤

data_list = [1, 2, 3, 4, 5]
print("choice({0}) => {1}".format(data_list, choice(data_list))) // 하나선택
print("choice({0}) => {1}".format(data_list, choices(data_list, k=2))) //중복 OK
print("sample({0}) => {1}".format(data_list, sample(data_list, k=2))) // 중복 X

shuffle(data_list) // 섞어서 반환
print("data_list => {0}".format(data_list))

###from datetime import 

from datetime import datetime, timezone, timedelta

now = datetime.now()
print("{0}-{1:02}-{2:02} {3:02}:{4:02}:{5:02}".format(now.year, now.mouth, now.day, now.hour, now.minute, now.second))

fmt = "%Y{0} %m{1} %d{2} %H{3} %M{4} %S{5}"
print(now.strftime(fmt).format(*"년월일시분초"))

##from datetime import datetime

##from pytz import commont_timezones, timezone, utc

form datetime import datetime
from pytz import common_timezones, timezone, utc

for tz in list(common_timezones): //common_timezones 입력값이 있으며 
	if tz.lower().find("paris") >=0: // paris 가있으면 시작 인덱스 값으 반환 없을경우 -1 반환
    	print(tz)
        
tz_utc = timezone(utc.zone)
tz_seoul = timezone("Asia/Seoul")
tz_pacific = timezone("US/Pacific")
tz_paris = timezone("Europe/Paris")


fmt = "%Y-%m-%d %H:%M:%S %Z%z"   /// %Z 객체 나라  %Z UTC시간차이


#UTC 현재 시각
now_utc = datetime.now(tz_utc)
print(now_utc.strftime(fmt))

#Asia/Seoul.strftime(fmt))
now_seoul = now_utc.astimezone(tz_seoul)
print(now_seoul.strftime(fmt))

# US/Pacific 타임존
now_pacific = now_seoul.astimezone(tz_pacific)
print(now_pacific.strftime(fmt))

# Europ/Paris 타임존
now_paris = now_pacific.astimezone(tz_paris)
print(now_paris.strftime(fmt))

 

#__name__

def plus(x, y):
	return x + y
    
    
def minus(x, y):
	return x - y
    
if __name__ == "__main__":
	print("plus(3, 2) => {0}".format(plus(3, 2)))
    print("minus(3, 2) => {0}".format(minus(3, 2)))
    
    
    
    
    //// 아직 잘 모르겟다
    //메인에 서언된 def 에서 이름을 찾으면 실행한다는 건가???

#패키지 사용

from package_mycalc import

op1, op2 = 2, 3

result = module_mycalc_1.plus(op1, op2)
print("plus({0}, {1}) => {2}".format(po1, po2, result))

result = module_mycalc_1.minus(op1, op2)
print("minus({0},[1})=> {2}".format(op1, op2, result))

result = module_mycalc_2.multiply(op1, op2)
print("multiply({0}, {1}) => {2}".format(po1, po2, result))

result = module_mycalc_2.divide(op1, op2)
print("divide({0},[1})=> {2:.2}".format(op1, op2, result))

##로또번호 생성기

import random

lotto = random.sample(range(1, 46, 1), 6)
print(sorted(lotto))   // sorted 오름차순 정열 함수

def imput_start()
	start = 0
    try:
    	start = int(input("로또 번호의 시작 번호를 입력하세요 (기본값: 1): "))
    except:
    	start = 1 
    finally:
    	return start
        
def input_end():
	end = 0
    try:
    	end = int(input("로또 번호의 끝작 번호를 입력하세요 (기본값: 45): "))
    except:
    	end = 45
    finally:
    	return end
        
def input_count():
	count = 0
    try:
    	count = int(input("로또 번호의 시작 번호를 입력하세요 (기본값: 1): "))
    except:
    	count = 6
    finally:
    	return count
        
        
def print_lotto(start, end, count):
	lotto = random.sample(rage(start, end +1, 1), count)
    print("행운의 로또 번호는 ", end="")
    print(sorted(lotto0, end="")
    for i, num in enumerate(sorted(lotto)):
    	if i ==len(lotto) - 1:
        	print("{0} ".format(num), end="")
        else:
        	print({0}, ".format(num), end="")
     
	print("입니다")
    
    

### import lotto

import lotto

start = lotto.input_start()
end = lotto.input_end()
count = lotto.input_count()

lotto.print_lotto(start, end, count)

'+++++SW 일일 공부+++++ > SW Expert Aademy' 카테고리의 다른 글

Python 튜플  (0) 2020.01.28
리스트 조작법  (0) 2020.01.24
Python 구문오류와 예외  (0) 2020.01.11
가변함수에 대하여  (0) 2020.01.11
실행 관련 함수  (0) 2020.01.11
블로그 이미지

Or71nH

,