Review


#1



https://www.codecademy.com/courses/python-intermediate-en-7mgOa/2/3?curriculum_id=4f89dab3d788890003000096#

My codes are running successfully, Thanks Code.cademy.

Basing on this "Who needs to pay for grade calculation software when you can write your own? :)", how can i save these codes using my IDLE (Python 3.6 32-bit) on my laptop to use it to calculate my students grades? i am a teacher . Thanks in advance for your guidance. any improvements need on the codes please.


grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(grades):
    for grade in grades:
        print grade

def grades_sum(grades):
    total = 0
    for grade in grades: 
        total += grade
    return total
    
def grades_average(grades):
    sum_of_grades = grades_sum(grades)
    average = sum_of_grades / float(len(grades))
    return average

def grades_variance(scores):
    average = grades_average(scores)
    variance = 0
    for score in scores:
        (average - score) ** 2
        variance = variance +  ((average - score) ** 2)
    return variance / len(scores)
def grades_std_deviation(variance):
    return variance ** 0.5
variance = grades_variance(grades)  
print grades_std_deviation(variance)
print print_grades(grades)
print grades_sum(grades)
print grades_average(grades)
print grades_variance(grades)
print grades_std_deviation(grades_variance(grades))

#any guidance much appreciated


#2

you can use a text-editor to save the file as .py file, just like you would save it as any other file

then you can just run it with: python name_you_gave_to_file.py from command line


#3

thank you, i saved it d.py, and when i double click on it nothing displays, it only blinks shortly and disappear . am new to these things, am sorry if i sound boring. asking is healthy than assuming you know.


#4

Its because the program closes once it finishes running

what we could do is prompt the user for input to confirm they want to exit, add this code to the end:

input("press any key to exit")

that should do the the trick

the alternative is to open the python file from command prompt, open start menu and type cmd in search area. This will give you the command prompt, navigate to where you store the python file, and run it with python d.py

If you don't know how to navigate the command prompt, google this. In short, you can do cd directory_name to navigate to a directory. cd .. to travel up one directory, tab key to autocomplete a folder name, and dir to list the files and directories in current directory


#5

thank you so much for the guidelines.. .i salute you


#6

using input() you can also enter students grades, just don't forgot to convert to integer (int()), allowing you to extend your program. You should by now have enough experience to figure out how to allow you to make multiply entries (using loop), so you can enter the student grades


#7

oh yeah, am still working on it, thanks for the reminder. :slight_smile:


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.