<div>유저에게 파일을 받아서 유저가 원하는 계산을 한뒤 다른 파일에 옮겨적는 프로그램 작성중입니다.</div> <div><span style="font-size:9pt;">define 을 해서 그 def 를 이용해서 계산후 옮겨적으려고하는데</span></div> <div><span style="font-size:9pt;">이 def를 어떻게 적용시키고 write 하는걸 어떻게 알고리듬 짜야할지 모르겠어서 질문드립니다.</span></div> <div><span style="font-size:9pt;">굳이 답안은 안주셔도되지만 큰 그림이라도 그릴수있게 도와주시면 감사할것같습니다. 조언이라도 ㅠㅠ </span></div> <div><br></div> <div><br></div> <div># The program for calculate value from the txt file or csv(exel) file</div> <div>print('Hello!')</div> <div>print('This program is for the calculate the value from your first file and rewrite at the another file.')</div> <div>print('Please follow the right order of this progaram.')</div> <div>print()</div> <div><br></div> <div>def 1:</div> <div> infileline = line.rstrip().split(",")</div> <div> infileline.sort()</div> <div> total = float(infileline[0]) + float(infileline[1]) + float(infileline[2]) + float(infileline[3])</div> <div><br></div> <div># Get the input and output file from the user by input function</div> <div>inputname = input('Enter the input file name or location of the file: ' )</div> <div>outputname = input('Enter the output file name or location of the file: ' )</div> <div><br></div> <div># Open the file of input and output</div> <div>infile = open(inputname, "r")</div> <div>outfile = open(outputname, "w")</div> <div><br></div> <div>while True:</div> <div> #Display menu</div> <div> print ("------calculate------")</div> <div> print ("1. ADDITION")</div> <div> print ("2. MEAN")</div> <div> print ("3. STANDARD DEVIATION")</div> <div> print ("4. MEDIAN")</div> <div> print ("5. MODE")</div> <div> print ("6. MINIMUM")</div> <div> print ("7. MAXIMUM")</div> <div> print ("---------------------")</div> <div> menu = int(input("Select the number in the menu"))</div> <div><br></div> <div> # Input validation: Select the number between 1 to 7</div> <div> while menu not in selection:</div> <div> menu = int(input("Select the number "))</div> <div><br></div> <div> # Perform calculation based on the selection</div> <div> if menu == 1:#ADDITION</div> <div> print('Your addition calculation is complete.')</div> <div> elif menu == 2:#MEAN</div> <div> print('Your mean calculation is complete.')</div> <div> elif menu == 2:#STANDARD DEVIATION</div> <div> print('Your standard deviation calculation is complete.')</div> <div> elif menu == 2:#MEDIAN</div> <div> print('Your median calculation is complete.')</div> <div> elif menu == 2:#MODE</div> <div> print('Your mode calculation is complete.')</div> <div> elif menu == 2:#MINIMUM</div> <div> print('Your minimum calculation is complete.')</div> <div> elif menu == 2:#MAXIMUM</div> <div> print('Your maximum calculation is complete.')</div> <div><br></div> <div> # Prompt the user to continue or not</div> <div> choice = input("Do more work? (y/n): ")</div> <div> while choice. capitalize() !='Y' and choice.capitalize() !='N':</div> <div> choice = input("Please enter y or n: ")</div> <div><br></div> <div> # The user entered 'N', therefore exit the calculate</div> <div> if choice.capitalize() !='Y':</div> <div> print("BYE-BYE")</div> <div> print("SEE-YA")</div> <div><br></div> <div>infile.close()</div> <div>outfile.close()</div> <div>break</div> <div><br></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.