Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python function that takes as input a string and returns an integer that represents the sum of the word, such as the rank

Write a python function that takes as input a string and returns an integer that represents the sum of the word, such as the rank of each letter in the alphabet represents its value. However, if the string contains 3 times the same letter, if the repeated letter is an "a" the function will return the sum of the other letters + 500, if not, it will return the sum of the other letters + 100. Also, if the letters are in a consecutive order the function will return 300, and if the only letter in the string is "a" or "z" the function will return 50. You are not allowed to use any dictionary dict(), or lambda, or set(), or all...etc. Keep it simple please.

The function has to look like this:

>>> value_of_word("abc"):

300

>>> value_of_word("a"):

50

>>> value_of_word("rarer")

106

>>> value_of_word("banana")

516

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

How would you assess the value of an approach like this?

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago