11# Kind of a sudo command but its name is super and it gives use you "supercommands" that a normal user can't use. Password is SECRETCOMMAND
2-
3- def supercommand (command ):
2+ def supercommand ():
43 password = "SECRETCOMMAND"
54 enter = input ("What's the secret password? Say it:" )
65 if enter == password :
7- # If the password is correct, you can use the commands above:
8- # Type command is repeating what you wrote.
9- if command == "type" :
10- input ("Type something:" )
11- return input ()
12- # Superexit command let's you exit the super command without ending the application.
13- elif command == "superexit" :
14- return "Superexiting..."
15- # I integrated my own calculator program named PMDMcalc in PyTerm.
16-
6+ # If the password is correct, you can use the commands above:
7+ while True :
8+ command = input ("You're in super mode. Type any supercommand:" ).strip ().lower ()
9+ if command == "type" :
10+ typed_text = input ("Type something:" )
11+ return typed_text
12+ elif command == "superexit" :
13+ return "Superexiting..."
14+ elif command == "superhelp" :
15+ return "type, superexit, superhelp,"
16+ else :
17+ print ("No such command in super mode." )
18+ else :
19+ return "Wrong password! You can't use the super command without the password."
20+
1721def pmdmcalc ():
1822 operation = input ("hint: + - / *. Type the symbol here: " ).strip ()
1923
20- if operation == "+" or operation == " +" :
24+ if operation in [ "+" , " +" ] :
2125 num1 = float (input ("Number 1: " ))
2226 num2 = float (input ("Number 2: " ))
23- result = num1 + num2
24- return f"Result: { result } "
27+ return f"Result: { num1 + num2 } "
2528
26- elif operation == "-" or operation == " -" :
29+ elif operation in [ "-" , " -" ] :
2730 num1 = float (input ("Number 1: " ))
2831 num2 = float (input ("Number 2: " ))
29- result = num1 - num2
30- return f"Result: { result } "
32+ return f"Result: { num1 - num2 } "
3133
32- elif operation == "/" or operation == " /" :
34+ elif operation in [ "/" , " /" ] :
3335 num1 = float (input ("Number 1: " ))
3436 num2 = float (input ("Number 2: " ))
35- result = num1 / num2
36- return f"Result: { result } "
37+ return f"Result: { num1 / num2 } "
3738
38- elif operation == "*" or operation == " *" :
39+ elif operation in [ "*" , " *" ] :
3940 num1 = float (input ("Number 1: " ))
4041 num2 = float (input ("Number 2: " ))
41- result = num1 * num2
42- return f"Result: { result } "
42+ return f"Result: { num1 * num2 } "
4343
4444 else :
4545 return "Your symbol is not supported in PMDMcalc. Please try again with another symbol."
4646
4747def handle_command (command ):
4848 command = command .strip ().lower ()
49- # Help command let's you see all the commands in PyTerm.
49+ # Help command lets you see all the commands in PyTerm.
5050 if command == "help" :
5151 return "Available commands: help, exit, info, pmdm, super"
52- # Exit command helps you exit the PyTerm application.
52+ # Exit command helps you exit the PyTerm application.
5353 elif command == "exit" :
5454 return "Exiting..."
55- # Info command let's you know the version of PyTerm and other data.
55+ # Info command lets you know the version of PyTerm and other data.
5656 elif command == "info" :
57- return ( """
57+ return """
5858PPPP y y TTTTT EEEE RRRR M M
5959P P y y T E R R MM MM
6060PPPP y T EEE RRRR M M M
@@ -65,22 +65,21 @@ def handle_command(command):
6565 Python: v3.8
6666 Created: Twenty-Third April 2024
6767 Operating System: MacOS
68- """ )
69- # PMDM command let's you use PMDMcalc directly from PyTerm.
68+ """
69+ # PMDM command lets you use PMDMcalc directly from PyTerm.
7070 elif command == "pmdm" :
7171 return pmdmcalc ()
72- # Told about super at the start.
72+ # Told about super at the start.
7373 elif command == "super" :
74- return supercommand (command )
75- # If there's no commands that you entered, it shows an error.
74+ return supercommand ()
75+ # If there's no commands that you entered, it shows an error.
7676 else :
7777 return "PyTerm: unknown command"
78- # Let's you use the terminal without ending it everytime when entered a command.
78+
79+ # Lets you use the terminal without ending it every time when entered a command.
7980while True :
8081 user_input = input ()
8182 output = handle_command (user_input )
8283 print (output )
83- if user_input .lower ().strip () == "superexit" :
84- handle_command ()
8584 if user_input .lower ().strip () == "exit" :
8685 break
0 commit comments