foundation of programming

1 answer below »
Answered Same DayMay 11, 2021

Answer To: foundation of programming

Yogesh answered on May 14 2021
149 Votes
import os
# main function to show menu of file operations...
def main():
    # Menu...
    print("*"*2
6)
    print("1. Read from a File.")
    print("2. Write to a File.")
    print("3. Rename a File.")
    print("4. Delete a File.")
    print("5. Quit.")
    
    # Take option input..
    ip1 = input("Choose an Option from above: ")
    
    # input Validation and call respective function as per input...
    if ip1 == "1":
        print('\n')
        readFile()
    elif ip1 == "2":
        print('\n')
        writeFile()
    elif ip1 == "3":
        print('\n')
        renameFile()
    elif ip1 == "4":
        print('\n')
        deleteFile()
    elif ip1 == "5":
        quit()
    else:
        print("Invalid input...\n")
        main()
        
# Read file function...
def readFile():
    # Input File Name...
    fname = input("To read File enter FileName: ")
    
    # try & except block to handle exceptions...
    try:
        # Open file in...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here