health = 10
defend = 0


drsp = input("defend")
if drsp == "yes":
    defend += 1

arsp = input("attack")
if arsp == "yes":
    if drsp == "yes":
        health -= 1
    if drsp == "no":
        health -= 2
if arsp == "no":
    health += 1

print(health)
8
import random


health = 10
slash = 1
jab = 2
punch = 3
moveLs = [slash, jab, punch]

def select(output):
    movenum = random.randrange(3)
    print(moveLs[movenum])
    output -= moveLs[movenum]
    print(output)

select(health)
print(health)
3
7
10
import random

health = 10
healthOp = 10
meg = "damage done to"
attacks = [1,2,3,4,5]

def attack(output):
    global health
    global healthOp
    movenum = random.randrange(5)
    output -= movenum

def attackD(output):
    global health
    movenum = random.randrange(5)
    movenum -= 2
    health -= attacks[movenum]

print("Choices: Attack, Defend")

choice = input("What will you do?")

if choice.lower() == "attack":
    attack(healthOp)
    attack(health)
if choice.lower() == "defend":
    attackD(health)
    print(health)

attackD(health)
print(health)
print(healthOp)
Choices: Attack, Defend
8
4
10
opChoice = ["attack", "defend"]
health = 10
healthOp = 10
def opponent():
    x = "nothing"
    global health
    global healthOp
    def op():
        op = random.randrange(2)
        nonlocal x
        x = opChoice[op]
    op()
    print(x)
    if x == "attack":
        health -= 3
    if x == "defend":
        healthOp -= 2

opponent()
print(health)
print(healthOp)
defend
10
8
import random

sword = 20
hammer = 30
num3 = [1,2,3]
def function(output):
    global equip
    equip = output

def durability():
    global equip
    dur = random.randrange(3)
    equip -= num3[dur]


print("You have a sword and a hammer, what weapon would you like to select?")
choice = input("Choose a weapon")
if choice.lower() == "hammer":
    function(hammer)
if choice.lower() == "sword":
    function(sword)

choice2 = input("Would you like to attack?")
if choice2.lower() == "yes":
    durability()

print(equip)
def cum():
    pass
You have a sword and a hammer, what weapon would you like to select?
27
print("filler")
print(9 == 12)
filler
False
import random

sword = 20
hammer = 30
num3 = [1,2,3]
healthOp = 10 #buff
health = 10 #buff
equipped = 0
attackList = { #use a list to define different enemies
    "jab": 3,
    "stab": 2,
    "crab": 5 #probably change method of attack layout
}
def equip(output):
    global equipped
    equipped = output
def durLow():
    global equipped
    dur = random.randrange(3)
    equipped -= num3[dur]
def choose():
    global choice
    choice = input("What would you like to do?")
    if choice.lower() == "equip":
        print("What would you like to equip?")
        chooseEquip()
        choose()
    elif choice.lower() == "attack": #add attack choices, do pp thing that pokemon does
        if equipped > 0:
            attack()
            durLow()
        else:
            print("You must have a weapon to fight")
            choose()
    elif choice.lower() == "defend":
        global health
        duck = input("With hands or weapon?")
        dip = random.randrange(3)
        if duck.lower() == "weapon":
            dip -= 1
            durLow() #nerf durability loss for defend
        health -= dip
    elif choice.lower() == "check":
        statCheck()
        choose()
    elif choice.lower() == "break":
        global healthOp
        healthOp = 0
    else:
        print("You can not do "+str(choice)+", please do something else")
        choose()
def chooseEquip():
    don = input("Choose a weapon")
    if don.lower() == "hammer":
        equip(hammer)
    elif don.lower() == "sword":
        equip(sword)
    else:
        print("You do not have "+str(don)+", please choose a weapon")
        chooseEquip()
def attackOp():
    global health
    health -= 1
def attack():
    global healthOp
    healthOp -= 2
def statCheck():
    print("Your health: "+str(health))
    print("Your opponent's health: "+str(healthOp))
    if equipped > 0:
        print("Your weapon's durablility: "+str(equipped))
    else:
        print("You must have a weapon equipped to check its durability")

print("There is an enemy in front of you. You have a sword and hammer. You must equip one to fight")
print("You can fight, check battle statistics, and defend. To equip a weapon you must type 'equip'")
while healthOp > 0:
    choose()
    attackOp()
    if health <= 0:
        break
if health <= 0:
    print("You died")
if healthOp <= 0:
    print("You win")
print("End stats:")
statCheck()
There is an enemy in front of you. You have a sword and hammer. You must equip one to fight
You can fight, check battle statistics, and defend. To equip a weapon you must type 'equip'
What would you like to equip?
You do not have monkey, please choose a weapon
You do not have monkey, please choose a weapon
Your health: 10
Your opponent's health: 10
Your weapon's durablility: 20
Your health: 10
Your opponent's health: 10
Your weapon's durablility: 20
Your health: 9
Your opponent's health: 8
Your weapon's durablility: 17
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
You can not do , please do something else
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in <cell line: 74>()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=72'>73</a> print("You can fight, check battle statistics, and defend. To equip a weapon you must type 'equip'")
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=73'>74</a> while healthOp > 0:
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=74'>75</a>     choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=75'>76</a>     attackOp()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=76'>77</a>     if health <= 0:

/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=42'>43</a> elif choice.lower() == "check":
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=43'>44</a>     statCheck()
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=44'>45</a>     choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=45'>46</a> else:
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=46'>47</a>     print("You can not do "+str(choice)+", please do something else")

/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=45'>46</a> else:
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=46'>47</a>     print("You can not do "+str(choice)+", please do something else")
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=47'>48</a>     choose()

/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=45'>46</a> else:
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=46'>47</a>     print("You can not do "+str(choice)+", please do something else")
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=47'>48</a>     choose()

    [... skipping similar frames: choose at line 48 (16 times)]

/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=45'>46</a> else:
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=46'>47</a>     print("You can not do "+str(choice)+", please do something else")
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=47'>48</a>     choose()

/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb Cell 8 in choose()
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=20'>21</a> def choose():
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=21'>22</a>     global choice
---> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=22'>23</a>     choice = input("What would you like to do?")
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=23'>24</a>     if choice.lower() == "equip":
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/kkcbal/vscode/madeacopy/_notebooks/2022-09-23-rpg.ipynb#X10sdnNjb2RlLXJlbW90ZQ%3D%3D?line=24'>25</a>         print("What would you like to equip?")

File ~/anaconda3/lib/python3.9/site-packages/ipykernel/kernelbase.py:1075, in Kernel.raw_input(self, prompt)
   1071 if not self._allow_stdin:
   1072     raise StdinNotImplementedError(
   1073         "raw_input was called, but this frontend does not support input requests."
   1074     )
-> 1075 return self._input_request(
   1076     str(prompt),
   1077     self._parent_ident["shell"],
   1078     self.get_parent("shell"),
   1079     password=False,
   1080 )

File ~/anaconda3/lib/python3.9/site-packages/ipykernel/kernelbase.py:1120, in Kernel._input_request(self, prompt, ident, parent, password)
   1117             break
   1118 except KeyboardInterrupt:
   1119     # re-raise KeyboardInterrupt, to truncate traceback
-> 1120     raise KeyboardInterrupt("Interrupted by user") from None
   1121 except Exception:
   1122     self.log.warning("Invalid Message:", exc_info=True)

KeyboardInterrupt: Interrupted by user
def tri_recursion(k):
  if(k > 0):
    result = k + tri_recursion(k - 1)
    print("heoo")
    print(result)
  else:
    result = 0
  return result

print("\n\nRecursion Example Results")
tri_recursion(6)

Recursion Example Results
heoo
1
heoo
3
heoo
6
heoo
10
heoo
15
heoo
21
21