import random
characterNameOne=str(input("Please input first character's name"))
characterNameTwo=str(input("Please input second character's name"))
print("The characters have 2 attributes : Strength and Skill")
dieOne = random.randint(1,4)
dieTwo = random.randint(1,12)
print ("A 12 and 4 sided dice are rolled")
print("Each character is set to 10")
characterOneStrength = 10
characterOneSkill = 10
characterTwoStrength = 10
characterTwoSkill = 10
DivisionValue=round((dieTwo/dieOne),0)
print("The number rolled on the 12 sided dice is divided by the number rolled on the 4 sided dice")
characterOneStrength += DivisionValue
characterOneSkill += DivisionValue
characterTwoStrength += DivisionValue
characterTwoSkill += DivisionValue
print ("The value of the divided dice is added to the character's attributes")
print('Character one , your strength:',str(characterOneStrength) + '\n')
print('Character one, your strength:',str(characterOneSkill) + '\n')
print('Character two, your strength:',str(characterTwoStrength) + '\n')
print('Character two, your strength:' ,str(characterTwoSkill) + '\n')
fileObj = open("CharacterAttributes.txt","w")
fileObj.write('str(CharacterNameOne),your strength:' + str(characterOneStrength) + '\n')
fileObj.write('str(characterNameOne), your skill:' + str(characterOneSkill) + '\n')
fileObj.write('str(characterNameTwo),your strength:' + str(characterTwoStrength) + '\n')
fileObj.write('str(characterNameTwo), your skill:' + str(characterTwoSkill) + '\n')
fileObj.close()
Hi , I wrote this code as a draft for a controlled assessment at school . The task is :
When determining certain characteristics of a game character the numbers on a combination of dice are used to calculate certain attributes.
Two of these attributes are strength and skill.
At the start of the game, when the characters are created, a 4 sided dice and a 12 sided dice are thrown to determine values for each of these attributes using the following method for each character:
Each attribute is initially set to 10. The score on the 12 sided dice is divided by the score on the 4 sided dice and rounded down. This value is added to the initial value. This process is repeated for each attribute for each character. Describe this process using a suitable algorithm.
Write and test the code to determine these two attributes for a character and store the sample data for two characters, including suitable names, in a file.
I wanted to know in this piece of code how to add in the variable that has the character name the user inputs. I have tried but it wont work :
print('Character one , your strength:',str(characterOneStrength) + '\n')
Also , any suggestions on how I could make the code shorter or more efficient. Thanks