On 11/04/13 07:08, Arijit Ukil wrote: > Thanks for the help. Now I have modifed the code as: > > import sys > > def main(argv): > data = int(sys.argv[1]) > avg = average (data) > print "Average:", avg > > def average(num_list): > return sum(num_list)/len(num_list)
Note that in Python 2.2-2.7 if sum returns an integer the division may not be what you expect. >>> 3/2 1 >>> 3/2.0 1.5 You may want to convert either the numerator or denominator to a float. It does not matter which as long as one of them is a float. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor