'목록하단 광고 치환자(withSeok)
728x90
A340

 

# 튜플의 패킹, 언패킹

_tu=(1,2,3)
a,b,c=_tu   # 튜플 요소를
print(a)    # 각 변수에 할당
print(b)
print(c)
A341

# 튜플 메소드
_tu=(1,5,3,1,1,6,2,2)
#    0 1 2 3 4 5 6 7
print(_tu.count(1),"개")
print(_tu.count(2),"개");print()
print(_tu[1]," : 2번째 요소")
print(_tu.index(2)," : 요소 중 2의 처음 위치")
A342

# 튜플을 활용햔 Python mini program

def f_square(n) :
  _area=n*n
  _circumference=4*n
  _volume=n**3
  return(_area,_circumference,_volume)

k=int(input('사각형 한 변의 길이는? : '));print()
(a,c,v)=f_square(k)
print(f'정사각형 넓이= {a},   둘레= {c}')
print(f'정육면체 부피= {v}')
A343

 

 

A344

 

 

A345

 

 

A346

 

 

A347

 

 

A348

 

 

A349

 

 

728x90

+ Recent posts