튜플은 한번 정해진 내용은 바꿀 수 없는 자료형
set은 중복된 내용이 없는 숫자 자료형
students = ['김성예','신경도','박기준','최승철','황동석']
print('--인덱스가 짝수인 학생 --')
for i in range(len(students)):
if i % 2 == 0 :
print(f'students[{i}] : {students[i]}')
print('--인덱스가 홀수인 학생 --')
for i in range(len(students)):
if i % 2 != 0 :
print(f'students[{i}] : {students[i]}')
for 또는 while
favSport = ['수영','배구','야구','조깅']
for i in range(len(favSport)) :
print(f'myFavSport [{i}] : {favSport[i]}')
studentCnt = [[1,18],[2,19]]
count = 0
sumStudnet = 0
averStudent = 0
for classNO, students in studentCnt :
print(f'{classNO}학습 학생 수 : {students}')
count +=1
sumStudnet += students
averStudent = int(sumStudnet/count)
print(f'전체 학생 수 : {sumStudnet}명')
print(f'평균 학생 수 : {averStudent}명')
minscore = 60
kor = int(input('국어점수입력'))
eng = int(input('영어점수입력'))
math = int(input('수학점수입력'))
scoreList = [['kor', kor], ['eng', eng],['math', math]]
for subject, score in scoreList:
if score < minscore :
print(f'{subject} 과락! 점수 :{score}, 기준 : {minscore}')
studentList = [[1,18],[2,19],[3,23]]
sum = 0
count = 0
average = 0
n = 0
while n < len(studentList) :
classNo = studentList[n][0]
studnetNo = studentList[n][1]
sum += studnetNo
count += 1
n += 1
print(f'{classNo}학급 학생수 : {studnetNo}')
continue
print(f'전체 학급 학생수 {sum}')
average =int(sum/count)
print(f'전체 학급 평균 학생 수 {average}')
minScore = 60
kor = int(input('kor'))
eng = int(input('eng'))
math = int(input('math'))
science = int(input('science'))
history = int(input('history'))
scoreList = [
['kor', kor],
['eng', eng],
['math', math],
['science', science],
['history', history]
]
n = 0
while n <len(scoreList):
subject = scoreList[n][0]
score = scoreList[n][1]
if scoreList[n][1] < minScore:
print(f'{subject}의 점수 {score}는 {minScore}보다 작기 때문에 과락')
n += 1
continue
clasList = [
[1, 18],
[2, 19],
[3, 23]]
maxStudent = 0
minStudent = 0
maxClass = 0
minClass = 0
n = 1
while n < len(clasList) :
if minStudent == 0 or minStudent > clasList[n][1]:
minStudent = clasList[n][1]
minClass = clasList[n][0]
if maxStudent == 0 or maxStudent < clasList[n][1]:
maxStudent = clasList[n][1]
maxClass = clasList[n][0]
n+=1
continue
print(f'학생 수가 가장 적은 학급 : {minClass}학급({minStudent}명)')
print(f'학생 수가 가장 많은 학급 : {maxClass}학급({maxStudent}명)')
