Code: Select all
print(f"Enter seed number:")
seednum = input()
print(f"Welcome to SUM IT UP and see if you're COMPATIBLE game")
print(f"To exit type stop. \nTo begin type in a word you'd like to have summed up:")
while True:
letter_to_number = {chr(97 + i): int(seednum) * (i + 1) for i in range(26)} # 97 is the ASCII code for 'a'
# Function to calculate the sum of assigned values for a word
def word_to_number(word):
word = word.lower() # Convert the word to lowercase for case-insensitivity
total = sum(letter_to_number.get(letter, 0) for letter in word)
return total
# Input a word from the user
input_word = input()
if input_word == 'stop':
break
else:
# Calculate and print the sum of assigned values for the word
result = word_to_number(input_word)
print(f"{input_word},{result}")
Chat GPT written code:
Code: Select all
while True:
letter_to_number = {chr(97 + i): 7 * (i + 1) for i in range(26)} # 97 is the ASCII code for 'a'
def word_to_number(word):
word = word.lower() # Convert the word to lowercase for case-insensitivity
total = sum(letter_to_number.get(letter, 0) for letter in word)
return total
input_word = input("Enter a word: ")
result = word_to_number(input_word)
print(f"The sum of assigned values for '{input_word}' is: {result}")
NOTE: Script like this can be used to generate datasets in a database and analysis can be run in the results. Here I just created a simple set of data, but the complexity can increase indefinitely.