# Learning python, lost with script

**URL:** <https://community.unix.com/t/learning-python-lost-with-script/355957>\
**Category:** Programming\
**Created:** [October 10, 2015, 9:55am UTC](https://community.unix.com/t/learning-python-lost-with-script/355957 "2015-10-10T09:55:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![la2015](https://community.unix.com/letter_avatar/la2015/32/6_22734026db12803ebb3e059622ac3534.png) [@la2015](https://community.unix.com/u/la2015)\
**Post date:** [October 10, 2015, 9:55am UTC](https://community.unix.com/t/learning-python-lost-with-script/355957/1 "2015-10-10T09:55:00Z")

</div>

Hi there,

im just having a hard time understanding why this code does not print anything that is suppose to print:

```nohighlight
score = raw_input ('what is your score? \n')

try:

        if 1.0 == float(score) >= 0.9:
            print "A"

        elif 0.9 > float(score) >= 0.8:
            print "B"

        elif 0.8 > float(score) >= 0.7:
            print "C"

        elif 0.7 > float(score) >= 0.6:
            print "D"
    
        elif 0.6 > float(score):
            print "F"

except:

            print "bad score"

```

whereas this other one does do the job correctly:

```nohighlight
score = raw_input ('please provide a score between 0.0 and 1.0\n')

try:

    if float(score) >= 0.9 and float(score) <= 1.0:

        print "A"  

    elif float(score) >= 0.8 and float(score) < 0.9:

        print "B"

    elif float(score) >= 0.7 and float(score) < 0.8:

        print "C"

    elif float(score) >= 0.6 and float(score) < 0.7:

        print "D"

    elif float(score) < 0.6:

        print "F"

except:
    print "Bad score"

```

Any insight?

---------- Post updated at 08:55 AM ---------- Previous update was at 08:44 AM ----------

Ok, I got it, the right way to define a numerical range is as in the second option. But why then I dont get any error if the first code is not written properly?

---

<div class="post-metadata">

**Author:** ![balajesuri](https://community.unix.com/user_avatar/community.unix.com/balajesuri/32/1423_2.png) [@balajesuri](https://community.unix.com/u/balajesuri)\
**Post date:** [October 12, 2015, 4:53am UTC](https://community.unix.com/t/learning-python-lost-with-script/355957/2 "2015-10-12T04:53:11Z")

</div>

Because for python it's a perfectly valid expression.

When you say, `1.0 == float(score) >= 0.9` ,  
python understands it as `1.0 == float(score) and float(score) >= 0.9`  
which will always evaluate to false unless `score` is 1.0
