#프로그래밍 언어간 번역
챗GPT가 매우 유용한 이유 중 또 다른 하나는 바로 한 언어에서 다른 언어로 프로그램을 이식하는 일이 가능하다는 것입니다.
이에 대한 일반적인 용도는 이전 언어의 코드를 최신 언어로 업그레이드 하는 것이죠!
Prompt ↓
Act like an experienced developer with knowledge of both COBOL and Python. Please convert this COBOL program to Python: IDENTIFICATION DIVISION. PROGRAM-ID. CALCULATE-SS-TAX. DATA DIVISION. WORKING-STORAGE SECTION. 01 SALARY PIC 9(7)V99. 01 SS-TAX PIC 9(7)V99. PROCEDURE DIVISION. DISPLAY "Enter employee's salary: ". ACCEPT SALARY. COMPUTE SS-TAX = SALARY * 0.062. DISPLAY "Social Security tax is: $", SS-TAX. STOP RUN.
Output ↓
salary = float(input("Enter employee's salary: ")) ss_tax = salary * 0.062 print("Social Security tax is: $", round(ss_tax, 2))
#여러가지 파일 처리와 코드베이스 리팩터링
챗GPT가 여러 파일을 처리하도록 하려면 어떻게 해야 할까요? 우리의 친구 챗GPT는 파일 이름을 제공하고 각각에 대한 코드를 붙여넣기만 하면 끝이랍니다!
Prompte ↓
My Python script uses two files, listed below, in different directories. Please display the output from executing conversation.py: BEGIN FILE 1: ./phrases/coming_and_going.py def hi(name): print(f"Hello, {name}!") def bye(name): print(f"Goodbye, {name}!") BEGIN FILE 2: ./conversation.py from phrases.coming_and_going import hi, bye hi("John") bye("John") Hello, John! Goodbye, John!
Output ↓
Hello, John! Goodbye, John!