Problem#
- Today's task is to write a small game that generates characters, similar to the code in [[100 Days of Python - Day 25]], but more complex.
- The first complexity lies in the character's health, which is more complex, and the second is the addition of the character's strength function.
- Reviewed knowledge points on 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 attribute (human, elf, wizard, orc): ")
print("Health: ", health())
print("Strength: ", strength())
again = input("Generate another one? yes or no")
Translation: