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