Problem#
- Today's task is to write a small game that generates characters, similar to the code from [[100 days to learn python - day 25]], but more complex.
- The first complexity lies in the character's health being more intricate, and the second is adding a strength function for the character.
- Reviewing knowledge points of os, random, while, and def.
#
CODE#
import random, os
again = "yes"
def sided():
n1 = random.randint(1, 6)
n2 = random.randint(1, 12)
n3 = n1 * n2
return n3
def health():
n1 = sided() / 2 + 10
return n1
def strength():
n1 = sided() / 2 + 12
return n1
while again == "yes":
os.system("clear")
print("Character Generation Game")
uname = input("Enter the character's name: ")
utype = input("Enter the character's type (human, elf, wizard, orc)")
print("Health: ", health())
print("Strength: ", strength())
again = input("Generate another one? yes or no")