Python - combination


def combination(m,n):
    if n==0 or m==n:
        return 1
    else:
        return combination(m-1,n)+combination(m-1,n-1)
    
    
m = int(input('please fill m value :'))
n = int(input('please fill n value :'))
ans = combination(m,n)
print(ans)

Python - summation


def summation(num):
    if num == 1:
        return 1
    else:
        return num + summation(num-1)

n = int(input('please fill in an integer number :'))
ans = summation(n)
print('the result is :', ans)

Python - adding label


def label(sentence):
    y = str('

') + sentence + str('

') print(y) s = str(input('please paste code :')) ans = label(s)

Python - 查日期


from datetime import datetime
#import datetime
def ymd():
    now = datetime.now()
    return (now.year, now.month, now.day)
y, m, d = ymd()
print(y,m,d)

Python - 質數檢查


import math
def prime(num):
    j = 2
    while j<=math.sqrt(num):
        if(num % j == 0):
            return False
        j += 1
    return True
for i in range(2,101):
    if prime(i):
        print(i,'is prime number')

English writing practice 2025-5/11

After graduating from university and working for several years, I developed the mindset that a job should be related to one’s interests. Peo...