[Python Study] 025 day

2022. 2. 1. 21:42
1 2 print("Python study 025 day") #2022. 1.29.Sat cs
Python study 025 day
1
2
3
4
5
6
7
def threeFive():
    result = 0
    for n in range(1,1000):
        if n % 3 == 0 or n % 5 == 0:
            result += n
    return result
threeFive()
cs
233168

 

1
2
3
4
5
6
7
8
9
10
11
# 게시판 페이지 수 리턴하기
def getTotalPage(total, onePage):
    if total % onePage == 0:
        return total // onePage
    else :
        return total // onePage + 1
    
print(getTotalPage(30,9))
print(getTotalPage(10,5))
print(getTotalPage(11,9))
print(getTotalPage(40,10))
cs

 

4
2
2
4
1
2
3
4
5
6
7
8
9
#메모장 만들기
import sys
 
#sys.argv는 프로그램 실행 시 입력된 값들을 읽어 들일 수 있는 파이썬 라이브러리이다.
option = sys.argv[1]
memo = sys.argv[2]
 
print(option)
print(memo)
cs
-f
/Users/janghan/Library/Jupyter/runtime/kernel-5dc84d16-fc31-4f5c-a2af-0ece23529485.json
1
2
3
4
5
6
7
8
9
#memo.py
option = sys.argv[1]
 
if option == '-a':
    meomo = sys.argv[2]
    f = open('memo.txt','a')
    f.write(memo)
    f.write('\n')
    f.close()
cs

 

'Programming > Python' 카테고리의 다른 글

[Python Study] 026 day  (0) 2022.02.02
[Python Study] 024 day  (0) 2022.01.29
[Python Study] 023 day  (0) 2022.01.29
[Python Study] 022 day  (0) 2022.01.29
[Python Study] 021 day  (0) 2022.01.29

BELATED ARTICLES

more