Python Forum
First Try Skynet... How Can I improve?
Poll: Rate MY Code
You do not have permission to vote in this poll.
Bad
0%
0 0%
Okay
0%
0 0%
Good
0%
0 0%
Total 0 vote(s) 0%
* You voted for this item. [Show Results]

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First Try Skynet... How Can I improve?
#1
Hey Guys, so this is my first try doing my own Code. So how do you think? How can I improve my System? Any help will be appreciate. Please ignore my English as I am not a native English speaker.

print (" Welcome to The Skynet ")
identification = input (" Enter Your Identification ")
password = input (" Enter Your Password ")
if password == ("aaabbb"):
    print (" Verifying ID...")
else:
    print (" Access Denied.")
    print (" Intruder Alert")
    print (" GPS Scanning for Location")
    print (" Location Found")
    print (" Activate Theta Protocol")
    print ("Theta Protocol Activated")
    print ("Self Destruct Activated")
    print ("10 Seconds")
    quit()
print (" Verifying ID... ")
print ((" Verifying Completed. Welcome ") + identification)
CONTINUE = input ("Do You Want to Continue? ")
if CONTINUE == ("YES"):
    print ("   X Menu X   ")
    print (" 1. Nuclear Launch")
    print (" 2. Diplomatic")
    print (" 3. Blacklist")
    print (" 4. Log Out")
    action = input (" Please Choose The Option From The Following Menu ")
    if action == ("1"):
        CONFIRM = input (" Are Sure You Want to Launch The Nuclear? ")
        if CONFIRM == (" YES "):
            C1 = input (" To CONFIRM, Type NUCLEAR_WAR ")
            print ("Nuclear Launch Has Been Activated")
            print ("Countdown Begin in 30 Minutes")
        else:
            print (("Nuclear Launch Cancel. Thank You ") + identification)
            quit()
    if action == ("2"):
        print ("Choose the Country")
        print ("A. Russia")
        print ("B. China")
        print ("C. Malaysia")
        print ("D. Thailand")
        A1 = input (" Choose The Country ")
        if A1 == ("A"):
            print (" Peace Treaty Negotiation has been sent to Russia.")
            print ((" The World will be A Better World Thanks to You ") + identification)
        if A1 == ("B"):
            print (" A Delegation has been Sent to China.")
            print ((" May we Preserve the Future together. Thank You ") + identification)
        if A1 == ("C"):
            print (" Our Head of Secretary has been sent to Malaysia to strengthen our Partnership")
            print (" Malaysia is A Great Country, Our Partnership with Them Will bring a brighter Future")
            print ((" Thank You ") + identification)
        if A1 == ("D"):
            print (" Invitation has been sent to Thailand Ruler to discuss our Deal")
            print ((" Thank You ") + identification)
    if action == ("3"):
        print ("   MOST WANTED LIST   ")
        print (" a. 1 Fifa ")
        print (" b. 2 Star Wars ")
        print (" c. 3 Battlefield ")
        A2 = input ((" The End. Thank You ") + identification)
        quit ()
    if action == ("4"):
        print ((" Thank You ") + identification)
        
else:
    print ((" Thank You ") + identification)
Reply
#2
Check out the functions and text adventures tutorials linked to from my signature below. Also, learn to love triple quoted strings:

text = """
It turns out
that strings
can have more than one line in them
without even
using backslash n
"""
print(text)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
You call a quit() function several times, but that function isn't defined anywhere.
Reply
#4
quit() is defined in the interpreter, it raises a SystemExit exception. It shouldn't be used in production code, though.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
The Reason why I put quit is because I want my system to exit if we put the input. And as I research quit() is the only option to force it quit

The Reason why I put quit is because I want my system to exit if we put the input. And as I research quit() is the only option to force it quit
Reply
#6
It's AN option, not the only option.  And, in my opinion, it's the worst option.  A better option would be to wrap all your code in a function, and then call it.  When you want to quit, just return instead.
def main():
    while True:
        keep_going = input("Keep going? ")
        if keep_going.lower() not in ("y", "yes", "1", "true"):
            return

if __name__ == "__main__":
    main()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020