Assuming that the traits of a person can be determined by a number which is a summarization of the values in their name. For example, if a = 1, b = 2, c = 3, etc. then, the name Mathhoang would be 87.
A small snippet python can be:
1
2
3
4
5
6
| def calTraits():
input_ = input("enter name: ").lower()
sum_ = 0
for i in input_:
sum_ = sum_ + (ord(i) - 96)
return sum_
|
another way for it:
1
| sum([(ord(i) - 96) for i in input("enter name:").lower()])
|
The examples show that we can use python in many differnt ways to implement your ideas!
No comments:
Post a Comment