Tuesday, June 19, 2012

Practice of coding during UT clinic [ Electronegativity values difference between elements ]

The UT clinic was unhelpful to a large extent, so I practice programming on my own without any references.

a = raw_input("Please enter the 1st Electronegativity")
b = raw_input("Please enter the 2nd Electronegativity")

try:
    a = float(a)
    if a < 0:
        print "Invalid value"
        exit()

    b = float(b)
    if b < 0:
        print "Invalid value"
        exit()

except:
    print "Please enter valid float"
    exit()

if a > b:
    c = a - b
elif b > a:
    c = b - a

if c < 0.5:
    print "Difference is " + `round(c,2)`
    print "It is Non-Polar Covalent Bond"
    print "Temporary Charges"

if c > 0.5 and c < 2.0:
    print "Difference is " + `round(c,2)`
    print "It is Polar Covalent Bond"
    print "Permanent Charges"

if c > 2.0:
    print "Difference is " + `round(c,2)`
    print "It is Ionic Bond"
    print "Permanent Charges"

No comments:

Post a Comment