ð ä»äžåºŠå¯äœçšã«ã€ããŠãŸãšããã
I. ðš ã¯ããã«
å¯äœçšãæå°éã«æããããšã«ãã£ãŠãããã°ã©ã ã®äºæž¬å¯èœæ§ãåäžããåå©çšæ§ãé«ãŸããŸããå¯äœçšãå°ãªãé¢æ°ã¯ãä»ã®ã³ãŒãã§äœ¿ãããããä¿®æ£ãæ¡åŒµããããããããä¿å®æ§ãåäžããŸããåŸã£ãŠãå¯äœçšãæå°éã«æããããšã¯ãé«å質ãªããã°ã©ã ãäœæããäžã§éèŠãªèŠçŽ ã§ãã
æ¬èšäºã§ã¯å
·äœäŸãšå
±ã«ãå¯äœçšã«ã€ããŠä»äžåºŠãŸãšããããšãæå³ããŠãŸãã
A. ãã®èšäºã«ãããè«ã®é²ãæ¹æŠèŠ
ãã®èšäºã§ã¯ããŸãå¯äœçšã®å®çŸ©ãšèªæºã説æãããã®åé¡ç¹ãç¹å®ããŸãã
åé¡ç¹ãæããã«ãªã£ãäžã§ãå¯äœçšãæå°éã«ä¿ã€ããšã®éèŠæ§ã説æããå
·äœçãªæ¹æ³ãæ瀺ããŸãã
ãã®åŸãåŸæ¥å¡å€æ 管çã·ã¹ãã ã®å®è·µäŸãçšããŠãææ¡ãããæ¹æ³ãå®éã«ã©ã®ããã«æ©èœããå¯äœçšãæå°éã«æããå¹æãããããšãå®æããŸãã
æåŸã«ãåŸãããç¥èŠãããšã«èšäºå
šäœããŸãšããŸãã
B. ãã®èšäºã®åæãšãªãç¥è
ãã®èšäºãç解ããããã«ã¯ãåºæ¬çãªããã°ã©ãã³ã°ã®ç¥èïŒå€æ°ãé¢æ°ãå¶åŸ¡æ§é ãªã©ïŒãå¿ èŠã§ãã
C. ãã®èšäºã«æåŸ ã§ããããšã»æåŸ ã§ããªãããš
ãã®èšäºã§ã¯ãããã°ã©ãã³ã°ã«ãããå¯äœçšã®åºæ¬çãªæŠå¿µãšããããæå°éã«æããæ¹æ³ããããããã説æããŸããããããæåŸ ã§ããªãããšãšããŠã以äžã®ç¹ãæããããŸãã
- åŠè¡çãªè°è«ãæ·±ãçè«çèæ¯ã«ã¯è§ŠããŸããããã®èšäºã¯ãåå¿è åãã«å¯äœçšã«é¢ããåºæ¬çãªç解ãä¿ãããšãç®çãšããŠãããããé«åºŠãªæ°åŠãè«çåŠã«åºã¥ãè°è«ã¯è¡ããŸããã
- æ·±ãç解ãé«åºŠãªã¹ãã«ã®ç¿åŸãä¿èšŒãããã®ã§ã¯ãããŸããããã®èšäºãèªãããšã§ãå¯äœçšã«é¢ããåºæ¬çãªç¥èãåŸãããããšãç®æããŠããŸãããæ·±ãç解ãå®è·µçãªã¹ãã«ã®ç¿åŸã«ã¯ãããå°éçãªè³æãå®è·µçµéšãå¿ èŠã§ãã
ãã®èšäºãèªãããšã§ãããã°ã©ãã³ã°ã«ãããå¯äœçšã«é¢ããåºæ¬çãªç解ãæ·±ãããã®åé¡ç¹ãšå¯Ÿçã«ã€ããŠåŠã¶ããšãã§ããŸããããããããé«åºŠãªç解ãå®è·µçãªã¹ãã«ã身ã«ã€ããããã«ã¯ãå°éçãªè³æãå®è·µçµéšãç©ãããšãéèŠã§ãã
æ¬èšäºã§ã¯ããã°ã©ãã³ã°ã«ãããå¯äœçšã«ã€ããŠãŸãšããç解ããããšæããŸããå¯äœçšãšã¯ãã£ããäœã§ããããïŒæ¬¡ç« ã§ããŸãã¯å®çŸ©ãšèªæºããèŠãŠãããŸãããã
II. ð« ããã°ã©ãã³ã°ã«ãããå¯äœçšãšã¯äœã
A. å¯äœçšã®å®çŸ©ã»èªæº
1. å¯äœçšãšã¯äœã
å¯äœçšãšã¯ãããã°ã©ã ãå®è¡ãããéã«ããã®åäœã«ãã£ãŠãæåŸ
ããªãå¯æ¬¡çãªå€åãèµ·ããããšãæããŸãã
äŸãã°ãããé¢æ°ãåŒæ°ãšããŠåãåã£ãå€æ°ã®å€ãå€æŽããå Žåãããã¯å¯äœçšãšãªããŸããããã°ã©ã ãå¯äœçšãæã€ãšããã®ããã°ã©ã ã¯å€éšã®ç¶æ
ãå€åãããå¯èœæ§ããããããããã°ã©ã ã®æ¯ãèããäºæž¬ã§ããªããªããŸãã
ããã°ã©ãã³ã°ã«ãããå¯äœçšã«ã¯ã次ã®ãããªçš®é¡ããããŸãã
- å€æ°ã®å€ãå€æŽããå¯äœçš
- ãã¡ã€ã«ã«æžã蟌ãå¯äœçš
- ãããã¯ãŒã¯ã«æ¥ç¶ããå¯äœçš
- ã¡ã¢ãªã解æŸããå¯äœçš
2. "å¯äœçš"ã®èªæº
ãå¯äœçšããšããèšèã¯ãå»è¬åãå»ççåŠçœ®ã®å¯äœçšããç±æ¥ããŠããŸããå»çåéã§ã¯ãæ²»çç®ç以å€ã®æå³ããªãå¹æãæãèšèãšããŠäœ¿ãããŠããŸããããã°ã©ãã³ã°ã«ãããŠããåãããã«ãæåŸ ããªãçµæãçºçããããšãæãèšèãšããŠçšããããŠããŸãã
å¯äœçšã®å®çŸ©ãèªæºã«ã€ããŠããã£ããšããã§ãããã°ã©ã ã«å¯äœçšããããšãã£ããäœãåé¡ã«ãªãã®ã§ããããïŒ
III. ð€š å¯äœçšãããããåé¡ç¹
A. äºæž¬å¯èœæ§ã®äœäž
å¯äœçšãããããåé¡ç¹ãšããŠãé¢æ°ãåãå ¥åã«å¯ŸããŠç°ãªãåºåãè¿ãå Žåããåãé¢æ°ãè€æ°ååŒã³åºããå Žåã«ç°ãªãçµæãåŸãããå ŽåãæããããŸãããããã¯ããã°ã©ã ã®æ£ãããå®å®æ§ã«åœ±é¿ãäžããäºæž¬å¯èœæ§ã®äœäžã«ã€ãªãããŸãã
B. åå©çšæ§ã®äœäž
å¯äœçšãããããããäžã€ã®åé¡ç¹ãšããŠãåå©çšãé£ãããªãå ŽåãæããããŸãã
é¢æ°ããä»ã®ã³ãŒããšç«¶åãããããªã°ããŒãã«å€æ°ã䜿çšããããå€éšç¶æ
ãå€æŽããŠããŸãããã§ãã
ã§ã¯ãå ·äœçã«ãªãå¯äœçšã®å°ãªãããã°ã©ã ãäœãããšãããã°ã©ããŒã«ãšã£ãŠéèŠãªã®ã§ããããïŒ
IV. ðïž å¯äœçšãæå°éã«ä¿ã€ããšã®éèŠæ§
A. ã©ã®ããã«äºæž¬å¯èœæ§ãåäžããã®ãïŒ
å¯äœçšãæå°éã«ä¿ã€ããšã«ãã£ãŠãããã°ã©ã ã®äºæž¬å¯èœæ§ãåäžããŸããå¯äœçšã®ãªãé¢æ°ãåŒã³åºããããšããåäœã¯åžžã«åãã§ããããã«ãã£ãŠãããã°ã©ã ãäºæããªãåäœãããªããããããã°ã©ã ã®å質ãåäžããŸãã
äžæ¹ãå¯äœçšã®å€ãé¢æ°ã§ã¯ãåŒã³åºããããšãã®åäœãåžžã«åããšã¯éããŸãããå€éšã®ç¶æ
ãå€ããããã§ããããã¯ãäºæž¬å¯èœæ§ãäœããããä¿¡é Œæ§ãäœäžããããšãæå³ããŸãã
å ·äœçãªäºæž¬å¯èœæ§ãåäžããå Žé¢ãèŠãŠã¿ãŸããããäŸãã°ãå¯äœçšã®ãªãé¢æ°ã§ãã add_numbers é¢æ°ãèããŸãã
def add_numbers(a, b):
return a + b
ãã®ãããªé¢æ°ããçŽç²é¢æ°ãšåŒã³ãŸãã
ãã®é¢æ°ãåŒã³åºããšãåžžã«åãçµæãåŸãããŸããå¯äœçšãæå°éã«ä¿ã€ããšã§ããã®ãããªäºæž¬å¯èœãªåäœãå®çŸããããšãã§ããŸãã
äºæž¬å¯èœãšããããšã¯ãä»ã®ã³ãŒããšçµã¿åãããããããã¹ãã±ãŒã¹ãäœãããããšããããšãæå³ããŸãã
äžæ¹ãå¯äœçšã®ããé¢æ°ã§ãã random_add_numbers é¢æ°ãèããŸãã
import random
def random_add_numbers(a, b):
if random.random() < 0.5:
return a
ãã®é¢æ°ãåŒã³åºããšãã©ã³ãã ãªå€ã«ãã£ãŠãé¢æ°ã®çµæãç°ãªãå¯èœæ§ããããŸããçµæãåžžã«åãã§ã¯ãªããããäºæž¬å¯èœæ§ãäœäžããŠããŸããŸãã
äºæž¬å¯èœæ§ãäœããšããããšã¯ãä»ã®ã³ãŒããšçµã¿åããããšãã«äºæãã¬çµæãæããããããã¹ãã±ãŒã¹ãäœãã¥ãããšããããšãæå³ããŸãã
å¯äœçšãæå°éã«ä¿ã€ããšã«ãã£ãŠãããã°ã©ã ã®äºæž¬å¯èœæ§ãé«ãŸãã®ã§ããã¹ãããããå®å šã«åäœããé¢æ°ãå®çŸ©ã§ããŸãïŒ
B. ã©ã®ããã«åå©çšæ§ãåäžããã®ãïŒ
å¯äœçšãæå°éã«ä¿ã€ããšã«ãã£ãŠãã³ãŒãã®åå©çšæ§ãé«ããããšãã§ããŸãã
åãæ©èœãæã€ã³ãŒããè€æ°ç®æã«æ£åšããŠããå Žåãä¿®æ£ãåå©çšãå°é£ã«ãªããããéçºæéãå¢å ãããåå ã«ãªããŸãã
å ·äœçãªåå©çšæ§åäžã®å Žé¢ã«ã€ããŠèŠãŠã¿ãŸãããã
def add_numbers(a, b):
return a + b
ãã®äŸã¯çŽç²é¢æ°ã§å¯äœçšããªããåå©çšæ§ãé«ãã§ãããªããªããçŽç²é¢æ°ã¯å€éšã®ç¶æ ãå€æŽããªããããä»ã®ã³ãŒããæ©èœãšäŸåé¢ä¿ãæå°éã«ãªãããã§ãã
ããã«å¯ŸããŠãå ·äœçãªåå©çšæ§äœäžã®å Žé¢ã«ã€ããŠèŠãŠã¿ãŸãããã
counter = 0
def increment():
global counter
counter += 1 # å€éšã®ç¶æ
ãå€æŽããŠãã
return counter
ãã®äŸã¯å€éšã®ç¶æ
ãå€æŽããå¯äœçšããããåå©çšæ§ãäœãã§ãããªããªããå€éšã®ç¶æ
counter
ã«äŸåããŠãããããä»ã®ã¢ãžã¥ãŒã«ã§åå©çšããããã«ã¯å床counter
ãå®çŸ©ããªããã°ãããªããªãããã§ãã
å€éšã®ç¶æ
ãšã®äŸåæ§ã«ãã£ãŠãåå©çšããããã«ç§»ããªããã°ãããªãè·ç©ãå€ããªã£ãŠããŸããŸãã
以äžã®ããã«ãå¯äœçšãæå°éã«ä¿ã€ããšã§ãåãã³ãŒããç°¡æœã«åå©çšã§ãããããããã°ã©ã ã®åå©çšæ§ãåäžãããšããããšãããããŸãã
C. IVç« ã®ãŸãšã
å¯äœçšãæå°éã«ä¿ã€ããšã¯ããã®ããã«ããã°ã©ã ã®äºæž¬å¯èœæ§ãšåå©çšæ§ãé«ããããšãã§ããŸãã
äºæž¬å¯èœæ§ã®åäžã«ãã£ãŠããã¹ã¿ããªãã£ãå®å
šæ§ã®åäžãåŸãããšãåºæ¥ãŸãã
åå©çšæ§ã®åäžã«ãã£ãŠãéçºæéãççž®ã§ãããããã°ãæžããããšãã§ããããããããããã°ã©ããŒã«ãšã£ãŠãå¬ããç¶æ³ãçãŸããŸãã
ããã§ã¯ããå¯äœçšãæå°éã«ä¿ã€éèŠæ§ãã«ã€ããŠç解ã§ãããšããã§ãå¯äœçšãæžããããã«ã¯ãã©ã®ãããªææ³ããããã«ã€ããŠèããŠã¿ãŸãããã
V. ðââïž ããã°ã©ã å ã®å¯äœçšãæžããæ¹æ³
ããä¿¡é Œæ§ã®é«ãã³ãŒããæžããããã«ãããã°ã©ã å ã§å¯äœçšãæžããæ¹æ³ã説æããŸãã
A. çŽç²é¢æ°ã䜿ã
çŽç²é¢æ°ã䜿ãããšã§åŸãããã¡ãªãã
çŽç²é¢æ°ã䜿ãããšã§ãããã°ã©ã å ã§ã®å¯äœçšãæžããããšãã§ããŸãããã®ãããé¢æ°ã®ãã¹ãã容æã«ãªããåå©çšæ§ãé«ãŸããŸãã
çŽç²é¢æ°ã¯ã©ã®ããã«åäœãããïŒ
以äžã¯ãçŽç²é¢æ°ã®äŸã§ãããã®äŸã§ã¯ãåŒæ°ã®æ°å€ã2ä¹ããŠè¿ãé¢æ°ãå®çŸ©ããŠããŸãã
def square(x):
return x * x
ãã®é¢æ°ã¯ãåŒæ°x
ãå€æŽããããšãªãããã®å€ã®2ä¹ãè¿ããŸãããã®ãããªçŽç²é¢æ°ã䜿ãããšã§ãããã°ã©ã ã®å¯äœçšãæžããããšãã§ããŸãã
B. ç¶æ å€æ°ãé¿ãã
ç¶æ å€æ°ãé¿ããããšã§åŸãããã¡ãªãã
ç¶æ å€æ°ãé¿ããããšã§ãé¢æ°ã®å¯äœçšãæžããããšãã§ããŸãããã®ãããããã°ã©ã ã®ãã¹ããä¿å®æ§ãåäžãããã°ãé²ãããšãã§ããŸãã
ç¶æ å€æ°ã«é¢ããå ·äœäŸã¯ïŒ
-
ç¶æ å€æ°ãå©çšããŠããæªãäŸ
ç¶æ
å€æ°ãå©çšããæªãäŸãåæ²ããŸããããã®äŸã§ã¯ãã°ããŒãã«å€æ°counter
ã䜿çšããŠãé¢æ°ãåŒã³åºããã³ã«counter
ãã€ã³ã¯ãªã¡ã³ãããŸãã
counter = 0
def increment():
global counter
counter += 1
return counter
ãã®é¢æ°ã¯ãcounter
ã®å€ãå€æŽãããããå¯äœçšãæã¡ãŸãããŸãããã®é¢æ°ã¯ä»ã®é¢æ°ããªããžã§ã¯ããããåŒã³åºããããããã°ããŒãã«ã¹ã³ãŒãã§ã®counter
ã®å€æŽã¯ãããã°ã©ã å
šäœã«åœ±é¿ãäžããå¯èœæ§ããããŸãã
-
æ¹åäŸ
æ¹åäŸãšããŠãcounter
ãåŒæ°ãšããŠåãåãããã®å€ãã€ã³ã¯ãªã¡ã³ãããŠè¿ãé¢æ°ãå®çŸ©ããããšãã§ããŸãã
def increment(counter):
return counter + 1
ãã®ããã«ããããšã§ãã°ããŒãã«ã¹ã³ãŒãã§ã®counter
ã®å€æŽãé¿ããããšãã§ããŸãããŸãããã®é¢æ°ã¯åŒæ°ã®ã¿ã䜿çšãããããçŽç²é¢æ°ã§ãã
C. ã€ãã¥ãŒã¿ãã«ãªããŒã¿æ§é ã䜿ã
Pythonã§ã¯ãtupleãfrozensetãªã©ã®ã€ãã¥ãŒã¿ãã«ãªããŒã¿æ§é ãå©çšã§ããŸããããã«ãããé¢æ°ãããŒã¿ãå€æŽããå¯äœçšãæãŠãªããªããŸãã
ã€ãã¥ãŒã¿ãã«ãªããŒã¿æ§é ã®å ·äœäŸã¯ïŒ
以äžã¯ãtupleãå©çšããŠããŒã¿ãå€æŽããå¯äœçšãæé€ããäŸã§ãã
def add_employee(employees, new_employee):
return employees + (new_employee,)
def main():
employees = ("Alice", "Bob", "Charlie")
new_employee = "David"
updated_employees = add_employee(employees, new_employee)
print(updated_employees)
if __name__ == "__main__":
main()
D. å¯äœçšãæ瀺çã«ç®¡çãã
ãªãå¯äœçšãæ瀺çã«ç®¡çããã®ãïŒ
å¯äœçšãæ瀺çã«ç®¡çããããšã§ãããã°ã©ã å ã§ã®å¯äœçšãææ¡ãããããªããŸãããŸãã倧å€æ°ã®é¢æ°ã®æ¯ãèããäºæž¬ãããããªããããã°ã©ã ã®ä¿å®æ§ãåäžããŸãã
å¯äœçšã管çããæ¹æ³
ããã°ã©ãã³ã°ã«ãããŠãå¯äœçšãæå°éã«ä¿ã€ããšã§ä¿¡é Œæ§ãšåå©çšæ§ãé«ããããšãã§ããŸãã以äžã«ãå¯äœçšã管çããæ¹æ³ã®äŸã2ã€çŽ¹ä»ããŸãã
- åã·ã¹ãã ã䜿çšããŠå¯äœçšãæ瀺ãã
Pythonã§ã¯ãtyping
ã¢ãžã¥ãŒã«ã䜿çšããŠåãã³ããè¿œå ããå¯äœçšãæ瀺çã«ç€ºãããšãã§ããŸããããã«ãããé¢æ°ãå¯äœçšãæã€ããšãæ瀺çã«ç€ºããä»ã®éçºè
ããã®å¯äœçšãç解ãããããªããŸãã
以äžã¯ãPythonã§å¯äœçšãæ瀺ããäŸã§ãã
from typing import Callable
def side_effect_function() -> None:
# å¯äœçšãããåŠç
pass
def effectful_function(side_effect: Callable[[], None]) -> int:
# å¯äœçšãæã€é¢æ°
side_effect()
return 42
- é¢æ°ã®ããã¥ã¡ã³ããã³ã¡ã³ãã«å¯äœçšãèšè¿°ãã
é¢æ°ã®ããã¥ã¡ã³ããã³ã¡ã³ãã«å¯äœçšãæ瀺çã«èšè¿°ããããšã§ãä»ã®éçºè ãé¢æ°ã®æåãç解ãããããªããŸããPythonã§ã¯ãdocstringã䜿çšããŠé¢æ°ã®èª¬æãèšè¿°ããŸãã
以äžã¯ãPythonã§ã³ã¡ã³ãã«å¯äœçšãèšè¿°ããäŸã§ãã
def save_to_file(data: str) -> bool:
"""
ãã¡ã€ã«ã·ã¹ãã ã«ã¢ã¯ã»ã¹ããŠããŒã¿ãä¿åããŸãã
å¯äœçš: ãã¡ã€ã«ã·ã¹ãã ã«æ°ãããã¡ã€ã«ãäœæãããŸãã
:param data: ä¿åããããŒã¿
:return: ä¿åãæåããå Žåã¯Trueã倱æããå Žåã¯False
"""
# ãã¡ã€ã«ã·ã¹ãã ãžã®æžã蟌ã¿åŠç
E. ãŸãšã
ç¶æ
å€æ°ãå¶åŸ¡ããããšã¯ãäºæž¬å¯èœæ§ãšåå©çšæ§ãåäžãããããã«éèŠã§ãã
å¯äœçšãæ瀺çã«ããçŽç²é¢æ°ãã€ãã¥ãŒã¿ãã«ãªããŒã¿æ§é ã䜿çšããããšã§ãå¯äœçšãé©åã«ããããšãã§ããŸããããã«ãããã³ãŒãã®ä¿¡é Œæ§ãšåå©çšæ§ãåäžããå®å
šæ§ãæ
ä¿ãããããªããŸãã
ã§ã¯ãæåŸã«ãã£ãšå®è·µçãªäŸãèŠãŠã¿ãŸããããäŸãã°åŸæ¥å¡å€æ 管çã·ã¹ãã ã«ãããŠãã©ã®ããã«å¯äœçšãæžãããã§ããããïŒ
VI. ð åŸæ¥å¡å€æ 管çã·ã¹ãã ã®äŸ
æ¬ç« ã§ã¯ãå®è·µçãªäŸã䜿ã£ãŠããã°ã©ãã³ã°ã«ãããå¯äœçšãæå°éã«ä¿ã€æ¹æ³ã解説ããŸããå ·äœçã«ã¯ãçããã銎æã¿æ·±ãã§ãããåŸæ¥å¡å€æ 管çã·ã¹ãã ã«ãããããåŸæ¥å¡ãåºå€ããããšããæ©èœã®å®è£ ãäŸã«åããŸãã以äžãæ³å®ããä»æ§ã§ãã
A. æ³å®ããä»æ§
- åŸæ¥å¡ãåºå€ããããã«ã¯ããŸãåºå€æéãèšé²ããŸãã
- åºå€æéãèšé²ãããããã®åŸæ¥å¡ãåºå€ããããšãèšé²ããŸãã
- åºå€ããåŸæ¥å¡ã«å¯ŸããŠãåºå€ããæšã®éç¥ã衚瀺ããŸãã
- åºå€ããåŸæ¥å¡ããåºå€èšé²ã確èªã§ããããã«ããŸãã
B. æªãäŸ
ãŸããæªãäŸããèŠãŠãããŸãããã
以äžã®ã³ãŒãã¯ãäžèšã®ä»æ§ãæºãããã®ã®ãå¯äœçšãå€ãä¿¡é Œæ§ãåå©çšæ§ãäœãå®è£
ã§ãã
import time
import requests
employee_code = "12345"
def record_attendance():
# ã°ããŒãã«å€æ°ãé¢æ°å
ã§å€æŽ
global employee_code
# çŸåšã®æ¥æãååŸ
current_time = time.localtime()
# ãã¡ã€ã«ãéããŠåºå€èšé²ãè¿œèš
attendance_db = open("attendance_database.txt", "a")
attendance_db.write(employee_code + "," + time.strftime("%Y-%m-%d %H:%M:%S", current_time) + ",attendance\n")
attendance_db.close()
# åºå€æéã衚瀺
print("åºå€æéïŒ", time.strftime("%Y-%m-%d %H:%M:%S", current_time))
# åŸæ¥å¡ã³ãŒããéç¥ãããªã¯ãšã¹ããéä¿¡
requests.post('https://example.com/notify_attendance', data={'employee_code': employee_code})
ãã®ã³ãŒãã®åé¡ç¹ã¯ä»¥äžã®éãã§ãã
- æ¥æé¢æ°ãé¢æ°å ã§çŽæ¥è¡ãããŠããŸãã
- åºå€èšé²ã®ããŒã¿ããŒã¹ãžã®ã¢ã¯ã»ã¹ãé¢æ°å ã§çŽæ¥è¡ãããŠããŸãã
- ãã°ãé¢æ°å ã§çŽæ¥èšé²ããŠããŸãã
- éç¥ã®éä¿¡ãé¢æ°å ã§çŽæ¥è¡ãããŠããŸãã
- ã°ããŒãã«å€æ°ïŒemployee_codeïŒãé¢æ°å
ã§çŽæ¥äœ¿çšã»å€æŽããŠããŸãã
ã³ãŒãã®ä¿¡é Œæ§ãåå©çšæ§ãäœããªããŸããäŸãã°ãã°ããŒãã«å€æ°ãçŽæ¥äœ¿çšã»å€æŽããããšã§ãä»ã®éšåã§åœ±é¿ãçããå¯èœæ§ããããŸãããŸããããŒã¿ããŒã¹ãžã®ã¢ã¯ã»ã¹ãéç¥ã®éä¿¡ãçŽæ¥è¡ãããŠãããããä»ã®å Žæã§åå©çšããéã«å€æŽãå°é£ã§ãã
C. é ãè¿œã£ãŠãªãã¡ã¯ã¿ãªã³ã°
ãªãã¡ã¯ã¿ãªã³ã°ãè¡ããå¯äœçšãåé¢ããããšã§ä¿¡é Œæ§ãšåå©çšæ§ãåäžãããã¹ã¿ããªãã£ãåäžããŸãã以äžã«ãé ãè¿œã£ãŠå¯äœçšãåé¢ãããªãã¡ã¯ã¿ãªã³ã°ããã³ãŒãäŸã瀺ããŸãã
- æ¥æååŸ
ãŸããæ¥æååŸã®åŠçãåé¢ããŸããããã«ãããæ¥æååŸéšåããã¹ããåå©çšã容æã«ãªããŸãã
def get_current_time():
return time.localtime()
- ãã¡ã€ã«æäœã¯ã©ã¹
次ã«ãåºå€èšé²ã®ããŒã¿ããŒã¹ãžã®ã¢ã¯ã»ã¹ãè¡ãã¯ã©ã¹ãäœæãããã¡ã€ã«æäœãåé¢ããŸãã
class AttendanceDatabase:
def __init__(self, file_path):
self.file_path = file_path
def record_attendance(self, employee_code, current_time):
with open(self.file_path, "a") as attendance_db:
attendance_db.write(f"{employee_code},{time.strftime('%Y-%m-%d %H:%M:%S', current_time)},attendance\n")
- ãã¬ãŒã¯ã©ã¹
åºå€æéã衚瀺ããåŠçããã¬ãŒã¯ã©ã¹ã«åé¢ããåºåå ãæè»ã«å€æŽã§ããããã«ããŸãã
class Logger:
def log(self, message):
print(message)
- éç¥éä¿¡ã¯ã©ã¹
éç¥ã®éä¿¡ãè¡ãã¯ã©ã¹ãäœæãããªã¯ãšã¹ãæäœãåé¢ããŸãã
class Notifier:
def __init__(self, url):
self.url = url
def notify_attendance(self, employee_code):
requests.post(self.url, data={'employee_code': employee_code})
- ã°ããŒãã«å€æ°ã®åé€
ãããã®ã¯ã©ã¹ãšé¢æ°ãå©çšããŠãrecord_attendance
é¢æ°ãåå®çŸ©ããã°ããŒãã«å€æ°ãåŒæ°ãšããŠåãããã«å€æŽããŸãã
def record_attendance(employee_code, attendance_database, logger, notifier):
current_time = get_current_time()
attendance_database.record_attendance(employee_code, current_time)
logger.log(f"åºå€æéïŒ{time.strftime('%Y-%m-%d %H:%M:%S', current_time)}")
notifier.notify_attendance(employee_code)
ããã«ãããå¯äœçšãåé¢ãããä¿¡é Œæ§ãšåå©çšæ§ãåäžããŸããããŸããäŸåæ§æ³šå ¥ãå©çšããããšã§ããã¹ã¿ããªãã£ãåäžããŸããã
æ¬ç« ã§ã¯ãåŸæ¥å¡å€æ 管çã·ã¹ãã ã®äŸãéããŠãå¯äœçšãæå°éã«ä¿ã€æ¹æ³ãå®è·µçã«è§£èª¬ããŸããããªãã¡ã¯ã¿ãªã³ã°ã«ãããä¿¡é Œæ§ãšåå©çšæ§ãåäžãããã¹ã¿ããªãã£ãåäžããŸããã
ãã®ç« ãŸã§ã§ãå¯äœçšãæå°éã«ä¿ã€ããšã§åŸãããå©ç¹ãæ¹æ³ã詳ããåŠã³ãŸããããããããããã®ç¥èãå®è·µçã«æŽ»çšããããã«ã¯ãæåŸã«ãã£ãããšãŸãšããŠããå¿ èŠããããŸãã次ã®ç« ã§ã¯ãæ¬èšäºã§åŠãã å 容ãç·åçã«ãŸãšããæ¹ããŠå¯äœçšãæå°éã«ä¿ã€ããšã®éèŠæ§ãå確èªããŸãããŸããçšèªäžèŠ§ãéããŠãæ°ããªç¥èãæŽçããããç解ãæ·±ããããšãã§ããŸããæåŸã®ãŸãšããèŠãŠãããŸãããã
VII. ð ãŸãšã
A. å¯äœçšãæå°éã«ä¿ã€ããšã§åŸãããå©ç¹ã®å確èª
ãã®èšäºãéããŠãå¯äœçšãæå°éã«ä¿ã€ããšã§ããã°ã©ã ã®äºæž¬å¯èœæ§ãåäžããåå©çšæ§ãé«ãŸãããšãåãããŸãããããã«ãããããã°ã©ã å šäœãå®å®ããä¿¡é Œæ§ãåäžããŸãã
B. å¯äœçšãæå°éã«ä¿ã€ããã®æ¹æ³ã®ãŸãšã
- çŽç²é¢æ°ã䜿ã
- ç¶æ å€æ°ãé¿ãã
- ã€ãã¥ãŒã¿ãã«ãªããŒã¿æ§é ã䜿ã
- å¯äœçšãæ瀺çã«ç€ºã
ãããã®æ¹æ³ãå®è·µããããšã§ãå¯äœçšãæå°éã«æããããšãã§ããŸãã
C. ãã®èšäºã§ç»å ŽããçšèªäžèŠ§
- å¯äœçš
- äºæž¬å¯èœæ§
- åå©çšæ§
- çŽç²é¢æ°
- ç¶æ å€æ°
- ã€ãã¥ãŒã¿ãã«
D. æåŸã«
å¯äœçšãæèããããšã§ãããªãã®ããã°ã©ã ã¯ããä¿¡é Œæ§ãé«ããåå©çšæ§ãåäžããäºæž¬å¯èœæ§ãé«ãŸããŸãããšããã§ãããã¯å èšäºã¯GPT-3.5ã«æžããŠããã£ããšèšæ¶ããŠããã®ã§ãããç·šéããšãŠã倧å€ã§ãããç·šéã®åŠã³ãããããšãŠãæå€ã§ãã
Discussion