Extreme Thinking
python 改進寫法

2022-10-13


a,b,c=0,3,12
ls = ['Lilei',12,'male']
name,age,gender = ls
x = -5
y = x if x>=0 else -x
score=78
if 60 <= score <80:
    level='C'
level='C'
if level in ('A','B','C'):
  status = 'pass'
l,d,s,r = [1,2,3],[],{},''
if l:
    print('l is not empty!')
if d:
    print('l is not empty!')
if s:
    print('l is not empty!')
if r:
    print('l is not empty!')
math,physics,computer = 70,40,80
if any([math<60,physics<60,computer<60]):
    print ('not pass')
math,physics,computer = 70,40,80
if all([math>=60,physics>=60,computer>=60]):
    print ('pass')
seasons = ['spring','summer','autumn','winter']
for i,s in enumerate(seasons):
    print (i,':',s)