728x90
반응형
# mark1. py
marks = [90, 25, 67, 45, 80]
number = 0
for mark in marks:
number += 1
if mark >= 60:
print("%d번 학생은 합격입니다" %number)
else:
print("%d번 학생은 불합격입니다." %number)
# mark2. py
marks = [90, 25, 67, 45, 80]
number = 0
for mark in marks:
number += 1
if mark < 60: continue
print("%d번 학생 축하합니다. 합격입니다." %number)
# marks3.py
marks = [90, 25, 67, 45, 80]
for number in range(len(marks)):
if marks[number] < 60: continue
print("%d번 학생 축하합니다. 합격입니다." %(number + 1))
# *arguments
def add_many(*args):
result = 0
for i in args:
result += i
return result
def add_mul(choice, *args):
if choice == "add":
result = 0
for i in args:
result += i
elif choice == "mul":
result = 1
for i in args:
result *= result
return result
728x90
반응형
'Language > Python' 카테고리의 다른 글
How to use Numpy (0) | 2022.09.06 |
---|---|
Basic Python_ Class exam : FourCal_Sourcecode (0) | 2022.08.26 |
Python_11. Collection Management (0) | 2022.08.03 |
Python_10. Dictionary and Set (0) | 2022.08.01 |
Python_09. List and Tuple (0) | 2022.08.01 |