Пример #1
0
def main():
    if len(sys.argv) != 2:
        print("Usage: python caesar.py key")
        # return 1
        exit(1)
    else:
        for i in sys.argv[1]:
            if not i.isdigit():
                print("Usage: python caesar.py key")
                # return 1
                exit(1)
        cipher = int(sys.argv[1])

        print('plaintext: ', end='')
        plain = input()
        encrypted = ''
        for word in list(plain):
            for letter in word:
                if letter.isupper():
                    letter = chr(((ord(letter) + cipher - 64) % 26) + 64)
                    encrypted += letter
                elif letter.islower():
                    letter = chr(((ord(letter) + cipher - 96) % 26) + 96)
                    encrypted += letter
                else:
                    encrypted += letter
        print(f'ciphertext: {encrypted}')
Пример #2
0
def gold_room():
    print  "This room is  full of gold  how much do you take?"
    next= raw_input(">")
    if "0" in next or  "1" in next :
        how_much=int(next)
    else:        
        print  "man ,learn to  type a number!"
    if how_much <50:
        print "Nice  you  are not greedy .You Win"
    else:
        print "Your greedy bastard!"
        exit(0)
Пример #3
0
def gold_room():
    print("This room is full of gold. How much do you take?")

    choice=input("> ")
    if "0" in choice or "1" in choice:
        how_much=int(choice)
    else:
        dead("Man, learn to type a number.")

    if how_much < 50:
        print("Nice ,you're not greedy, you win!")
        exit(0)
    else:
        dead("you greedy bastard!")
Пример #4
0
                                def dead(why):
                                    print(why, "Good job!")
                                    exit(0)

                                    def start():
                                        print("You are in a dark room.")
                                        print("There is a door to your right and left.")
                                        print("Which one do you take?")

                                        choice = input("> ")

                                        if choice == "left":
                                            bear_room()
                                        elif choice == "right":
                                            cthulhu_room()
                                        else:
                                            dead("You stumble around the room until you starve.")


                                            start()
Пример #5
0
def gold_room():
    print "This room is full of gold. How much do you take?"

    next = raw_input(prompt)
    # original method
    # if "0" in next or "1" in next:
    #     how_much = int(next)
    # else:
    #     dead("Man, learn to type a number.")

    # more robust method
    try:
        how_much = int(next)
    except ValueError:
        dead("Man, learn to type a number.")

    if how_much < 50:
        print "Nice, you're not greedy, you win!"
        exit(0)
    else:
        dead("You greedy bastard!")
Пример #6
0
 def aktualizacja(self, idZadania, Args=None): # analizuje dzialania usera i zleca wykonanie odpowiednich dzialan
     args = []   # umieszczone tu zmienne wyladuja w argumentach metody main w zadaniu	
    
     if idZadania == Zadania["ZlePolecenie"] :
         self.strategia = ZlePolecenie()
     elif idZadania == Zadania["Login"] :
         if self.model.gracz :
             self.strategia = ZlePolecenie()
         else :
             args.append(self.model)
             args.append(self.widok)
             if Args :
                 args.append(Args[0]) #nick
                 args.append(Args[1]) #haslo
             self.strategia = login()
     elif idZadania == Zadania["exit"] :
         args.append(self.widok.czyscEkran)
         self.strategia = exit()
     elif idZadania == Zadania["Menu"] :
         args.append(self)
         self.strategia = Menu()
     elif idZadania == Zadania["help"] :
         self.strategia = help()
     elif idZadania == Zadania["ls"] :
         args.append(self.model)
         self.strategia = ls()
     elif idZadania == Zadania["cd"] :
         args.append(self.model)
         args.append(Args)
         self.strategia = cd()
     elif idZadania == Zadania["historia"] :
         self.strategia=historia()
     elif idZadania == Zadania["Register"] :
         if self.model.gracz :
             self.strategia = ZlePolecenie()
         else :
             args.append(self)
             self.strategia = Register()
     if self.strategia != 0 :
         self.strategia.main(args)
Пример #7
0
def dead(why):
    print(why,"Good job!")
    exit(0)
Пример #8
0
def gold_room():
    print("This room is full of gold. How much do you take?")

    choice = input("> ")
    if "0" in choice or "1" in choice:
        how_much = int(choice)
    else:
        dead("Man, learn to type a number.")

        if how_much < 50:
            print("Nice, you're not greedy, you win!")
            exit(0)
        else:
            dead("You greedy bastard!")


            def bear_room():
                print("There is a bear here.")
                print("The bear has a bunch of honey.")
                print("The fat bear is in front of another door.")
                print("How are you going to move the bear?")
                bear_moved = False

                while True:
                    choice = input("> ")

                    if choice == "take honey":
                        dead("The bear looks at you then slaps your face off.")
                    elif choice == "taunt bear" and not bear_moved:
                        print("The bear has moved from the door.")
                        print("You can go through it now.")
                        bear_moved = True
                    elif choice == "taunt bear" and bear_moved:
                        dead("The bear gets pissed off and chews your leg off.")
                    elif choice == "open door" and bear_moved:
                        gold_room()
                    else:
                        print("I got no idea what that means.")


                        def cthulhu_room():
                            print("Here you see the great evil Cthulhu.")
                            print("He, it, whatever stares at you and you go insane.")
                            print("Do you flee for your life or eat your head?")

                            choice = input("> ")

                            if "flee" in choice:
                                start()
                            elif "head" in choice:
                                dead("Well that was tasty!")
                            else:
                                cthulhu_room()


                                def dead(why):
                                    print(why, "Good job!")
                                    exit(0)

                                    def start():
                                        print("You are in a dark room.")
                                        print("There is a door to your right and left.")
                                        print("Which one do you take?")

                                        choice = input("> ")

                                        if choice == "left":
                                            bear_room()
                                        elif choice == "right":
                                            cthulhu_room()
                                        else:
                                            dead("You stumble around the room until you starve.")


                                            start()
Пример #9
0
	def enter():
		print "This room does not exist, you cannot not enter!!"
		exit(1)
Пример #10
0
	def enter(self):
		print Death.quips[randint(0, len(self.quips)-1)]
		exit(0)
Пример #11
0
"""setup.py~~~~~~~~Packaging information and tools."""

from os.path import abspath, dirname, join, normpathfrom subprocess import callfrom sys import exit
from setuptools import Command, find_packages, setup

class TestCommand(Command): """    The ``python setup.py test`` command line invocation is powered by this    helper class.    This class will run ``py.test`` behind the scenes and handle all command    line arguments for ``py.test`` as well. """    description = 'run all tests'    user_options = []
 def initialize_options(self): pass
 def finalize_options(self): pass
 def run(self): """Run the test suite.""" exit(call(['py.test', '--cov-report', 'term-missing', '--cov', 'ipify']))

setup(
 # Basic package information: name = 'ipify', version = '1.0.0', packages = find_packages(exclude=['tests']),
 # Packaging options: zip_safe = False, include_package_data = True,
 # Package dependencies: install_requires = [ 'backoff>=1.0.7', 'requests>=2.7.0',    ], tests_require = [ 'pytest>=2.7.0', 'pytest-cov>=1.8.1', 'python-coveralls>=2.5.0',    ],
 # Test harness: cmdclass = { 'test': TestCommand,    },
 # Metadata for PyPI: author = 'Randall Degges', author_email = '*****@*****.**', license = 'UNLICENSE', url = 'https://github.com/rdegges/python-ipify', keywords = 'python api client ipify ip address public ipv4 ipv6 service', description = 'The official client library for ipify: A Simple IP Address API.', long_description = open(normpath(join(dirname(abspath(__file__)), 'README.rst'))).read(), classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'License :: Public Domain', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Internet', 'Topic :: Software Development', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Utilities',    ],
)
Пример #12
0
@@ -4,19 +4,6 @@ from sys import exit
 from setuptools import find_packages, setup
 from setuptools.command.test import test as TestCommand
 
-
-class Tox(TestCommand):
-    def finalize_options(self):
-        TestCommand.finalize_options(self)
-        self.test_args = []
-        self.test_suite = True
-
-    def run_tests(self):
-        #import here, cause outside the eggs aren't loaded
-        import tox
-        errno = tox.cmdline(self.test_args)
-        exit(errno)
-
 long_description = u'\n\n'.join((
     open('README.rst').read(),
     open('CHANGELOG').read()
@@ -54,10 +41,5 @@ setup(
         'pygments>=1.6',
         'requests>=2.0.0',
     ],
-    tests_require=[
-        'tox>=1.6.1'
-    ],
-    cmdclass={
-        'test': Tox
-    },
+    test_suite='runtests.runtests',
Пример #13
0
 def enter(self):
     print("This scene is not yet configured.")
     print("Subclass it and implement enter().")
     exit(1)
Пример #14
0
def enter(self):
print("This scene isn't yet configured.")
print("Subclass it and implement enter().")
exit(1)
class Engine(object):
class Death(Scene):
def __init__(self, scene_map):
self.scene_map = scene_map
def play(self):
current_scene = self.scene_map.opening_scene()
last_scene = self.scene_map.next_scene('finished')
while current_scene != last_scene:
next_scene_name = current_scene.enter()
current_scene = self.scene_map.next_scene(next_scene_name)
current_scene.enter()
class Death(Scene):

quips = [
"You died. You kinda suck at this.",
"Your Mom would be proud...if she were smarter.",
"Such a luser.",
"I have a small puppy that's better at this.",
"You're worse than your Dad's jokes."
]
def enter(self):
print(Death.quips[randint(0, len(self.quips)-1)])
exit(1)
class CentralCorridor(Scene):

def enter(self):
print(dedent("""
The Gothons of Planet Percal #25 have invaded your ship and
destroyed your entire crew. You are the last surviving
member and your last mission is to get the neutron destruct
bomb from the Weapons Armory, put it in the bridge, and
blow the ship up after getting into an escape pod.
You're running down the central corridor to the Weapons
Armory when a Gothon jumps out, red scaly skin, dark grimy
teeth, and evil clown costume flowing around his hate
filled body. He's blocking the door to the Armory and
about to pull a weapon to blast you.
"""))
action = input("> ")
if action == "shoot!":
print(dedent("""
Quick on the draw you yank out your blaster and fire
it at the Gothon. His clown costume is flowing and
moving around his body, which throws off your aim.
Your laser hits his costume but misses him entirely.
This completely ruins his brand new costume his mother
bought him, which makes him fly into an insane rage
and blast you repeatedly in the face until you are
dead. Then he eats you.
"""))
return 'death'
elif action == "dodge!":
print(dedent("""Like a world class boxer you dodge, weave, slip and
slide right as the Gothon's blaster cranks a laser
past your head. In the middle of your artful dodge
your foot slips and you bang your head on the metal
wall and pass out. You wake up shortly after only to
die as the Gothon stomps on your head and eats you.
"""))
return 'death'
elif action == "tell a joke":
print(dedent("""
Lucky for you they made you learn Gothon insults in
the academy. You tell the one Gothon joke you know:
Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr,
fur fvgf nebhaq gur ubhfr. The Gothon stops, tries
not to laugh, then busts out laughing and can't move.
While he's laughing you run up and shoot him square in
the head putting him down, then jump through the
Weapon Armory door.
"""))
return 'laser_weapon_armory'
else:
print("DOES NOT COMPUTE!")
return 'central_corridor'
class LaserWeaponArmory(Scene):
def enter(self):
print(dedent("""
You do a dive roll into the Weapon Armory, crouch and scan
the room for more Gothons that might be hiding. It's dead
quiet, too quiet. You stand up and run to the far side of
the room and find the neutron bomb in its container.
There's a keypad lock on the box and you need the code to
get the bomb out. If you get the code wrong 10 times then
the lock closes forever and you can't get the bomb. The
code is 3 digits.
"""))
code = f"{randint(1,9)}{randint(1,9)}{randint(1,9)}"
guess = input("[keypad]> ")
guesses = 0
while guess != code and guesses < 10:
print("BZZZZEDDD!")
guesses += 1
guess = input("[keypad]> ")
if guess == code:
print(dedent("""
The container clicks open and the seal breaks, letting
gas out. You grab the neutron bomb and run as fast as
you can to the bridge where you must place it in the
right spot.
"""))
return 'the_bridge'
else:
print(dedent("""
The lock buzzes one last time and then you hear a
sickening melting sound as the mechanism is fused
together. You decide to sit there, and finally the
Gothons blow up the ship from their ship and you die.
"""))
return 'death'
class TheBridge(Scene):
def enter(self)
print(dedent("""
You burst onto the Bridge with the netron destruct bomb
under your arm and surprise 5 Gothons who are trying to
take control of the ship. Each of them has an even uglier
clown costume than the last. They haven't pulled their
weapons out yet, as they see the active bomb under your
arm and don't want to set it off.
"""))
action = input("> ")
if action == "throw the bomb":
    print(dedent("""
In a panic you throw the bomb at the group of Gothons
and make a leap for the door. Right as you drop it a
Gothon shoots you right in the back killing you. As
you die you see another Gothon frantically try to
disarm the bomb. You die knowing they will probably
blow up when it goes off.
"""))
return 'death'
elif action == "slowly place the bomb":
print(dedent("""
You point your blaster at the bomb under your arm and
the Gothons put their hands up and start to sweat.
You inch backward to the
Пример #15
0
def dead(why):
    print why, "Good job!"
    exit(0)
Пример #16
0
 def exit(self):
     exit(0)
     pass
Пример #17
0
 60   +    host.cmd('route add default gw %s dev %s-eth0' % (routerip, host.name))  
 61   +    ips = IP_SETTING[host.name].split(".")   
 62   +    host.cmd('route del -net %s.0.0.0/8 dev %s-eth0' % (ips[0], host.name))  
 63   +  
 64   +def get_ip_setting():  
 65   +    try:  
 66   +        with open(IPCONFIG, 'r') as f:  
 67   +            for line in f:  
 68   +                if( len(line.split()) == 0):  
 69   +                  break  
 70   +                name, ip = line.split()  
 71   +                print name, ip  
 72   +                IP_SETTING[name] = ip  
 73   +            info( '*** Successfully loaded ip settings for hosts\n %s\n' % IP_SETTING)  
 74   +    except EnvironmentError:  
 75   +        exit("Couldn't load config file for ip addresses, check whether %s exists" % IPCONFIG_FILE)  
 76   +  
 77   +def simplenet():  
 78   +    get_ip_setting()  
 79   +    topo = simpleTopo()  
 80   +    info( '*** Creating network\n' )  
 81   +    net = Mininet( topo=topo, controller=RemoteController, ipBase=IPBASE )  
 82   +    net.start()  
 83   +    host1, host2, host3, firewall = net.get( 'host1', 'host2', 'host3', 'sw0')  
 84   +    h1intf = host1.defaultIntf()  
 85   +    h1intf.setIP('%s/8' % IP_SETTING['host1'])  
 86   +    h2intf = host2.defaultIntf()  
 87   +    h2intf.setIP('%s/8' % IP_SETTING['host2'])  
 88   +    h3intf = host3.defaultIntf()  
 89   +    h3intf.setIP('%s/8' % IP_SETTING['host3'])  
 90   +  
Пример #18
0
    if ((choice == 1 and comp_choice == 2)
            or (choice == 2 and comp_choice == 1)):
        print("paper wins => ", end="")
        result = "paper"

    elif ((choice == 1 and comp_choice == 3)
          or (choice == 3 and comp_choice == 1)):
        print("Rock wins =>", end="")
        result = "Rock"
    else:
        print("scissor wins =>", end="")
        result = "scissor"

    # Printing either user or computer wins
    if result == choice_name:
        print("<== User wins ==>")
    else:
        print("<== Computer wins ==>")

    print("Do you want to play again? (Y/N)")
    ans = input()

    # if user input n or N then condition is True
    if ans == 'n' or ans == 'N':
        exit()

# after coming out of the while loop
# we print thanks for playing
print("\nThanks for playing :)")
input('press any key to exit.')