Tuesday, 10 May 2011

Python Program that shows percentage of love.

hi,

i made a python program to show the percentage of love.

the program has a lot of bugs. this is just an idea.

the code is,..

#/usr/bin/env python

firstName = raw_input("enter your name : ")
secondName = raw_input("enter your lover name : ")

if len(firstName) == 0 | len(secondName) == 0:
    print "enter the name"
else :
    name1List = list(firstName)
    name2List = list(secondName)
    alphabets = {}
    alphabets["a"]=10
    alphabets["b"]=11
    alphabets["c"]=27
    alphabets["d"]=19
    alphabets["e"]=27
    alphabets["f"]=15
    alphabets["g"]=24
    alphabets["h"]=34
    alphabets["i"]=13
    alphabets["j"]=9
    alphabets["k"]=13
    alphabets["l"]=8
    alphabets["m"]=11
    alphabets["n"]=6
    alphabets["o"]=25
    alphabets["p"]=28
    alphabets["q"]=31
    alphabets["r"]=21
    alphabets["s"]=12
    alphabets["t"]=19
    alphabets["u"]=14
    alphabets["v"]=18
    alphabets["w"]=26
    alphabets["x"]=20
    alphabets["y"]=32
    alphabets["z"]=29
    name1num = 0
    name2num = 0
    for letter in name1List:
        name1num = alphabets[letter] + name1num

    for letters in name2List:
        name2num = alphabets[letters] + name2num

    result = name1num+name2num
    if result > 100 :
        print "your love percentage is ",result%100,"%"
    else :
        print "your love percentage is ", result,"%"

i/p:

enter your name : ram
enter your lover name : sita

o/p:

your love percentage is  96 %

No comments:

Post a Comment