二手产品经理

二手产品经理

THIS IS RENO

Learn Python online for 100 days - Week 4, Day 6.

Problem#

  1. 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.
  2. 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.
  3. 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:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.