This is a follow up question to PyDOS shell simulation.
You might remember PyDOS from my other post. I have now updated it and it's better than ever! Post any ideas below that could make it better.
import time
import os
import sys
import random
def splash():
print ()
print ("PyDOS")
print ()
print ("Version 1.9.8")
print ()
time.sleep(3.2)
def calc():
while True:
print ("Welcome to PyCALC")
print ("Please type the number for your suggestion.")
print ("1: Addition\n2: Subtraction\n3: Multiplacation\n4: Division")
suggestion = input("Your Choice: ")
if suggestion == "1":
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
print ("Please wait...")
time.sleep(0.6)
answer = num1+num2
print ("Your answer is:")
print (answer)
break
if suggestion == "2":
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
print ("Please wait...")
time.sleep(0.6)
answer = num1-num2
print ("Your answer is:")
print (answer)
break
if suggestion == "3":
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
print ("Please wait...")
time.sleep(0.6)
answer = num1*num2
print ("Your answer is:")
print (answer)
break
if suggestion == "4":
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
print ("Please wait...")
time.sleep(0.6)
answer = num1/num2
print ("Your answer is:")
print (answer)
break
else:
print ("Your operation choice is invalid!")
def get_lines():
print("Enter 'stop' to end.")
lines = []
line = input()
while line != 'stop':
lines.append(line)
line = input()
return lines
def textviewer():
os.system('cls' if os.name == 'nt' else 'clear')
print ("Text Viewer.")
directory = ("/media/GENERAL/Projects/files")
filename = input("Enter a text file to view: ")
file = open(os.path.join(directory, filename), "r")
print ("Loading text...")
time.sleep(0.5)
os.system('cls' if os.name == 'nt' else 'clear')
print(file.read())
edit_text = input("Would you like to edit it? (y for yes, n for no)")
if edit_text == "y":
file = open(os.path.join(directory, filename), "w")
print ("You are now in edit mode.")
lines = get_lines
file.write('\n'.join(lines))
time.sleep(2)
if edit_text == "n":
print ("Press enter to exit")
input()
def edit():
os.system('cls' if os.name == 'nt' else 'clear')
print ("EDIT")
print ("-------------")
print ("Note: Naming this current document the same as a different document will replace the other document with this one.")
directory = ("/media/GENERAL/Projects/files")
filename = input("Plese enter a file name.")
file = open(os.path.join(directory, filename), "w")
print ("FILE: " + filename+".")
lines = get_lines()
file.write('\n'.join(lines))
def cls():
os.system('cls' if os.name == 'nt' else 'clear')
splash()
while True:
os.system('cls' if os.name == 'nt' else 'clear')
print ()
print ("PyDOS VERSION 1.9.5")
shell = input("> ")
if shell == "textviewer":
print ("Loading Text Viewer...")
time.sleep(3)
textviewer()
elif shell == "help":
print ("HELP")
print ("-----------------")
print ("Commands:")
print ("dir - displays directory.")
print ("cls - clears screen")
print ("help - shows help")
print ("textviewer - launches textviewer")
print ("edit - launches edit")
print ("news - launches news")
print ("shutdown - closes PyDOS")
print ("calc - launches calculator")
print ("------------------------------------")
print ("What is PyDOS?")
print ("PyDOS is inspired by MS-DOS made in the 1980's and")
print ("has that feel of it too! For a better experiance")
print ("run PyDOS in the python CMD shell.")
input ("Press enter to close.")
elif shell == "edit":
print ("Loading edit...")
time.sleep(3)
edit()
elif shell == "calc":
calc()
elif shell == "dir":
print ("The drive name is A:")
print ()
print ("NAME: TYPE: MODIFIED:")
print ("SHUTDOWN.EXE .EXE 12/01/15 ")
print ("EDIT.EXE .EXE 09/03/15 ")
print ("TEXTVIEWER.EXE .EXE 09/03/15 ")
print ("NEWS.EXE .EXE 09/01/15 ")
print ("HELP.COM .COM 09/03/15 ")
print ("HANGMAN(BROKEN).EXE .EXE 11/03/15 ")
print ("CALC.EXE .EXE 20/03/15 ")
input ("---------------Press enter to close---------------")
elif shell == "cls":
cls()
elif shell == "hangman":
hangman.main()
elif shell == "news":
print ("PyDOS NEWS")
print ()
print ("New Additions:")
print ()
print ("New calculator app!")
print ("All text documents from edit are now stored in a 'files' directory")
print ()
print ("Tweaks and fixes:")
print ()
print ("BUG023L: Fixed issue with splash screen loop")
print ()
print ("Reported Bugs:")
print ("BUG024T: Hangman returns a traceback error, we are fixing this!")
print ("BUG025T: Pressing 'y' in texteditor when it asks you if you want\nto edit the file returns Type_Error")
input("Press enter to close")
elif shell == 'shutdown':
print ("Shutting down...")
time.sleep(3)
break
else:
print("This command or file: "+shell+ " does not exist. Check for spelling errors and try again.\nIf you are trying to open a textfile, open textviewer.")
time.sleep(5)
os.system('cls' if os.name == 'nt' else 'clear')
HANGMAN(BROKEN).EXE
... you meanHANGMA~1.EXE
:p \$\endgroup\$