From admin.dslcomputer at gmail.com Wed Jul 8 19:42:18 2015 From: admin.dslcomputer at gmail.com (admin.dslcomputer at gmail.com) Date: Wed, 8 Jul 2015 17:42:18 +0000 Subject: [Seattle-pug] =?utf-8?q?Maximum_to_the_Minimum?= Message-ID: <559d618a.03a1440a.4222.ffff8459@mx.google.com> Hi Everyone: How do I rewrite the python script, below, to get a printout from the Maximum to the Minimum, and to convert a string into a number? largest = None smallest = None while True: num = raw_input("Enter a number") if num == "done" : break print num try: inp=raw_input("enter a number:") num = float(inp) except: print "Invalid Input" continue if smallest is None: smallest = value elif value < smallest: smallest = value elif largest is None: largest = value elif value > largest: largest = value print "Maximum is", largest print "Minimum is", smallest Regards, Hal -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin.dslcomputer at gmail.com Thu Jul 9 00:54:46 2015 From: admin.dslcomputer at gmail.com (admin.dslcomputer at gmail.com) Date: Wed, 8 Jul 2015 22:54:46 +0000 Subject: [Seattle-pug] =?utf-8?q?Fw=3A_=E2=80=98Maximum_is_None_and_the_?= =?utf-8?b?4oCYTWluaW11bSBpcyBOb25l4oCZ?= In-Reply-To: <559da4f6.2a80460a.43eb.ffff9d69@mx.google.com> References: <559da4f6.2a80460a.43eb.ffff9d69@mx.google.com> Message-ID: <559daa51.435e460a.6e4b.ffffa65f@mx.google.com> Hi Everyone: When the user enters a series of number integers, the output reads: ?Maximum is None and the ?Minimum is None? What is the source of the syntax Error, below: largest = None smallest = None while True: num = raw_input("Enter a number: ") if (num == "done") : break try: value = float(num) except ValueError: print "Invalid input" continue if smallest is None: smallest = value elif value < smallest: smallest = value print smallest, value if largest is None: largest = value elif value > largest: largest = value print largest, largest print "Maximum is", largest print "Minimum is", smallest Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin.dslcomputer at gmail.com Tue Jul 21 20:24:51 2015 From: admin.dslcomputer at gmail.com (admin.dslcomputer at gmail.com) Date: Tue, 21 Jul 2015 18:24:51 +0000 Subject: [Seattle-pug] =?utf-8?q?String_Error_Message?= Message-ID: <55ae8f94.2558460a.6358.ffffdd79@mx.google.com> Hi Everyone: I'm trying to write a python program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475 The program is designed to Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. However, line 10 displays the following string syntax error: SyntaxError: invalid syntax (, line 10) The raw URL link to the code is available at http://tinyurl.com/oa7cppq You can download the sample data at http://www.pythonlearn.com/code/mbox-short.txt Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin.dslcomputer at gmail.com Wed Jul 22 02:13:38 2015 From: admin.dslcomputer at gmail.com (admin.dslcomputer at gmail.com) Date: Wed, 22 Jul 2015 00:13:38 +0000 Subject: [Seattle-pug] =?utf-8?q?String_Utility_Question?= Message-ID: <55aee065.c487460a.1c8aa.5c5b@mx.google.com> Hi Everyone: Where can I find documentation on "line.split()" The Python online documentation site contains no available search term for "line.split()",i.e., URL link at https://www.python.org/downloads/release/python-279/ Moreover, the Python Library Reference refers to the utility function as an ArgumentParser: "def convert_arg_line_to_args(self, arg_line): return arg_line.split()", i.e., The Python Library Reference, Release 2.7.10; 15.4. argparse ? Parser for command-line options, arguments and sub-commands p. 475. Likewise, the Python Tutorial refers to the utility function as a Generator Expressions: "unique_words = set(word for line in page for word in line.split())?,i.e., Python Tutorial, Release 2.7.10; 9.11. Generator Expressions p. 75 Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From ltc.hotspot at gmail.com Tue Jul 28 22:17:28 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Tue, 28 Jul 2015 20:17:28 +0000 Subject: [Seattle-pug] =?utf-8?q?line_error_on_no=2E_7?= Message-ID: <55b7e41d.c385460a.ec17.3486@mx.google.com> Hi Everyone, I'm writing python code to read a data text file, split the file into a list of words using the split(function) and to print the results in alphabetical order. The raw python code is located at http://tinyurl.com/oua9uqx The sample data is located at http://tinyurl.com/odt9nhe Desired Output: ['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder'] There is a line error on no. 7 What is the cause of this error? Regards, Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin.dslcomputer at gmail.com Wed Jul 29 01:28:49 2015 From: admin.dslcomputer at gmail.com (admin.dslcomputer at gmail.com) Date: Tue, 28 Jul 2015 23:28:49 +0000 Subject: [Seattle-pug] =?utf-8?q?String_Attribute?= Message-ID: <55b81098.6937460a.b91e.ffffab3c@mx.google.com> Hi Everyone: What is the source of the syntax error to the String Attribute? Go to the following URL links and view a copy of the raw data file code and sample data: 1.) http://tinyurl.com/p2xxxhl 2.) http://tinyurl.com/nclg6pq Here is the desired output: stephen.marquard at uct.ac.za louis at media.berkeley.edu .... Hal Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: From ltc.hotspot at gmail.com Fri Jul 31 03:09:53 2015 From: ltc.hotspot at gmail.com (ltc.hotspot at gmail.com) Date: Fri, 31 Jul 2015 01:09:53 +0000 Subject: [Seattle-pug] =?utf-8?q?duplicate_line_output?= Message-ID: <55bacb37.0566420a.f7cc4.ffffb548@mx.google.com> Hi Everyone, Question: How do I remove each duplicate line output? Here is the raw data code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 for line in fh: if not line.startswith('From'): continue line2 = line.strip() line3 = line2.split() line4 = line3[1] print line4 count = count + 1 print "There were", count, "lines in the file with From as the first word" The problem is in the output results: Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v.1500 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 3.2.0 -- An enhanced Interactive Python. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: cd C:\Users\vm\Desktop\apps\docs\Python C:\Users\vm\Desktop\apps\docs\Python In [2]: %run _8_5_v_7.py Enter file name: mbox-short.txt stephen.marquard at uct.ac.za stephen.marquard at uct.ac.za louis at media.berkeley.edu louis at media.berkeley.edu zqian at umich.edu zqian at umich.edu rjlowe at iupui.edu rjlowe at iupui.edu zqian at umich.edu zqian at umich.edu rjlowe at iupui.edu rjlowe at iupui.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu gsilver at umich.edu gsilver at umich.edu gsilver at umich.edu gsilver at umich.edu zqian at umich.edu zqian at umich.edu gsilver at umich.edu gsilver at umich.edu wagnermr at iupui.edu wagnermr at iupui.edu zqian at umich.edu zqian at umich.edu antranig at caret.cam.ac.uk antranig at caret.cam.ac.uk gopal.ramasammycook at gmail.com gopal.ramasammycook at gmail.com david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za david.horwitz at uct.ac.za stephen.marquard at uct.ac.za stephen.marquard at uct.ac.za louis at media.berkeley.edu louis at media.berkeley.edu louis at media.berkeley.edu louis at media.berkeley.edu ray at media.berkeley.edu ray at media.berkeley.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu cwen at iupui.edu There were 54 lines in the file with From as the first word In [3]: Regards, Hal Sent from Surface Sent from Surface Sent from Surface Sent from Surface -------------- next part -------------- An HTML attachment was scrubbed... URL: