Advertisement
simeonshopov

Most powerful Word (july exam)

Nov 4th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import math
  2. word = input()
  3. key_char = [65, 69, 73, 79, 85, 89, 97, 101, 105, 111, 117, 121]
  4. score = 0
  5. winner_word = ""
  6. points = 0
  7.  
  8. while word != "End of words":
  9.   for i in word:
  10.     score += ord(i)
  11.   if ord(word[0]) in key_char:
  12.     score *= len(word)
  13.   else:
  14.     score /= len(word)
  15.   if score > points:
  16.     points = score
  17.     winner_word = word
  18.   score = 0
  19.   word = input()
  20. else:
  21.   print(f"The most powerful word is {winner_word} - {math.floor(points)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement