Character Stats
Write a program that will generate a character sheet for a Dungeons and Dragons game. The user should enter the name and class of their character. They will then have the four stats of the character generated. The whole character sheet should then be displayed to the user.
Name your character: Smiddy Choose a trait for your character: Brave, Great, Wise, etc Characters trait: Great Available classes are: Warrior, Cleric, Rogue, Mage Choose your class: Warrior CHARACTER SHEET Name: Smiddy the Great Class: Warrior Strength: 8 Dexterity: 5 Charisma: 9
DECLARE name, trait, name_with_trait, chosen_class AS STRING DECLARE strength, dexterity, charisma AS INTEGER OUTPUT "Name your character: " INPUT name OUTPUT "Choose a trait for your character: Brave, Great, Wise, etc" INPUT trait SET name_with_trait TO name + " the " + trait OUTPUT "Available classes are: Warrior, Cleric, Rogue, Mage" OUTPUT "Choose your class: " INPUT chosen_class SET strength TO RANDOM(1, 20) SET dexterity TO RANDOM(1, 20) SET charisma TO RANDOM(1, 20) OUTPUT "" OUTPUT "CHARACTER SHEET" OUTPUT "" OUTPUT "Name: ", name_with_trait OUTPUT "Class: ", chosen_class OUTPUT "Strength: ", strength OUTPUT "Dexterity: ", dexterity OUTPUT "Charisma: ", charisma
import random
name = str(input("Name your character: "))
print("Choose a trait for your character: Brave, Great, Wise, etc")
trait = str(input("Characters trait: "))
name_with_trait = name + " the " + trait
print("Available classes are: Warrior, Cleric, Rogue, Mage")
chosen_class = str(input("Choose your class: "))
strength = random.randint(1, 20)
dexterity = random.randint(1, 20)
charisma = random.randint(1, 20)
print("")
print("CHARACTER SHEET")
print("")
print("Name: ", name_with_trait)
print("Class: ", chosen_class)
print("Strength: ", strength)
print("Dexterity: ", dexterity)
print("Charisma: ", charisma)
# Required to generate random numbers
import random
# Get the name of the character from the user
name = str(input("Name your character: "))
# Prompt a trait from the user and then get the trait from the user
print("Choose a trait for your character: Brave, Great, Wise, etc")
trait = str(input("Characters trait: "))
# Combine the name with the trait for later use
name_with_trait = name + " the " + trait
# Allow the user to choose a class
print("Available classes are: Warrior, Cleric, Rogue, Mage")
chosen_class = str(input("Choose your class: "))
# Generate random stats
strength = random.randint(1, 20)
dexterity = random.randint(1, 20)
charisma = random.randint(1, 20)
# Display the character sheet to the user
print("")
print("CHARACTER SHEET")
print("")
print("Name: ", name_with_trait)
print("Class: ", chosen_class)
print("Strength: ", strength)
print("Dexterity: ", dexterity)
print("Charisma: ", charisma)
Extension
Extend the program to add another two stats. The program should then calculate the average stat and display that to one decimal place.
Name your character: Smiddy Choose a trait for your character: Brave, Great, Wise, etc Characters trait: Great Available classes are: Warrior, Cleric, Rogue, Mage Choose your class: Warrior CHARACTER SHEET Name: Smiddy the Great Class: Warrior Strength: 9 Dexterity: 17 Charisma: 4 Wisdom 18 Defense 19 Average Stat: 13.4