Problems with my first python script
<p>I am trying to write a simple grading script based off an existing script that i found in a tutorial online. The goal is to ask the user their score and give the corresponding grade.</p>

<p>Here is the original code:</p>

<pre><code>def letterGrade(score):
    if score &gt;= 90:
        letter = 'A'
    else:   # grade must be B, C, D or F
        if score &gt;= 80:
            letter = 'B'
        else:  # grade must be C, D or F
            if score &gt;= 70:
                letter = 'C'
            else:    # grade must D or F
                if score &gt;= 60:
                    letter = 'D'
                else:
                    letter = 'F'
    return letter
</code></pre>

<p><strong><em>this btw didnt work at all and i really dont get the "def" command since its not mentioned again? No errors</em></strong></p>

<p>Anyway, here is my new modified code from what i have been learning from books and online...</p>

<pre><code>score = float(input("What is your score"))
if score &gt;= 90:
    letter = 'A'
else:   # grade must be B, C, D or F
    if score &gt;= 80:
        letter = 'B'
    else:  # grade must be C, D or F
        if score &gt;= 70:
            letter = 'C'
        else:    # grade must D or F
            if score &gt;= 60:
                letter = 'D'
            else:
                letter = 'F'
print (letter)
input ("Press Enter to Exit")
</code></pre>

<p><strong><em>This code doesnt work either, but at least it is asking for user input now.  No errors</em></strong></p>

<p>What am i missing here?</p>

<p>Since you are a noobie, let me give you a few tips. </p>

<p>1: SO is hostile to easily google-able things</p>

<p>If you google "python def" you'll see that it's the keyword for defining a function. What's a function? <em>google</em>. Oh, a function is a block of code that can be called multiple times.</p>

<pre><code>def letterGrade(score):
    if score &gt;= 90:
        letter = 'A'
    else:   # grade must be B, C, D or F
        if score &gt;= 80:
            letter = 'B'
        else:  # grade must be C, D or F
            if score &gt;= 70:
                letter = 'C'
            else:    # grade must D or F
                if score &gt;= 60:
                    letter = 'D'
                else:
                    letter = 'F'
    return letter

print(letterGrade(95)) # A
print(letterGrade(70)) # C
print(letterGrade(20)) # F
</code></pre>

<p>2: "else" and "if" can be combined in python:</p>

<pre><code>def letterGrade(score):
    if score &gt;= 90:
        letter = 'A'
    elif score &gt;= 80:   # grade must be B, C, D or F
        letter = 'B'
    elif score &gt;= 70:  # grade must be C, D or F
        letter = 'C'
    elif score &gt;= 60:    # grade must D or F
        letter = 'D'
    else:
        letter = 'F'

    return letter
</code></pre>

python