二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 4 Day 6

Problem#

  1. 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.
  2. The first complexity lies in the character's health being more intricate, and the second is adding a strength function for the character.
  3. 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")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.