From 630df07f960439b38c8c693ecbd68fff6e99f32f Mon Sep 17 00:00:00 2001 From: sonnyali Date: Tue, 29 Mar 2016 20:23:31 -0400 Subject: [PATCH 1/8] new --- Assignments/assignment_Michael.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Assignments/assignment_Michael.py diff --git a/Assignments/assignment_Michael.py b/Assignments/assignment_Michael.py new file mode 100644 index 0000000..a6210c7 --- /dev/null +++ b/Assignments/assignment_Michael.py @@ -0,0 +1,2 @@ +x="Wello World" +print x \ No newline at end of file From 6b1b33018fe7fce957bbdbce8cc17f1ce8896e4a Mon Sep 17 00:00:00 2001 From: Nohely Date: Thu, 31 Mar 2016 20:40:52 -0400 Subject: [PATCH 2/8] new assignment --- Assignments/assignment2_Michael.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Assignments/assignment2_Michael.py diff --git a/Assignments/assignment2_Michael.py b/Assignments/assignment2_Michael.py new file mode 100644 index 0000000..21281a3 --- /dev/null +++ b/Assignments/assignment2_Michael.py @@ -0,0 +1,12 @@ +hours = raw_input ("enter hours:") +pay = raw_input("Enter pay rate:") + +total = float(hours) * float(pay) + +#hereis the amount I owe +# +# +# +# +# +print "hey I owe you", total \ No newline at end of file From 4de6a1ad6f8ca9eb7e30dbdedb9423582459b7a7 Mon Sep 17 00:00:00 2001 From: glennsvel90 Date: Tue, 12 Apr 2016 19:07:31 -0400 Subject: [PATCH 3/8] new --- Assignments/calc.py | 14 ++++++++++++++ Assignments/grade.py | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Assignments/calc.py create mode 100644 Assignments/grade.py diff --git a/Assignments/calc.py b/Assignments/calc.py new file mode 100644 index 0000000..7152460 --- /dev/null +++ b/Assignments/calc.py @@ -0,0 +1,14 @@ +hours = raw_input ("Enter Hours: ") +rate = raw_input ("Enter Rate: ") +h = float(hours) +r = float(rate) +if h > 40: + overtimeRate = 1.5 * r + overtime = (h-40) * overtimeRate + h = 40 + pay = h * r + overtime + print pay +else: + overtime = 0 + pay = h * r + overtime + print pay \ No newline at end of file diff --git a/Assignments/grade.py b/Assignments/grade.py new file mode 100644 index 0000000..f8a5542 --- /dev/null +++ b/Assignments/grade.py @@ -0,0 +1,20 @@ +score = raw_input("Enter Score: ") +s= float(score) +def grade(s): + if s >= 0.9: + return 'A' + elif s >= 0.8: + return 'B' + elif s >= 0.7: + return 'C' + elif s >= 0.6: + return 'D' + elif s < 0.6: + return 'F' + elif s > 1.0: + return 'error' + elif s < 0.0: + return 'error' + else: + return "no score" +print grade(s) \ No newline at end of file From 2be018e57a472179a91e8e3bc982216fa9b456bd Mon Sep 17 00:00:00 2001 From: dannyxboi Date: Thu, 21 Apr 2016 19:32:11 -0400 Subject: [PATCH 4/8] new --- Assignments/assiagnent6.5.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Assignments/assiagnent6.5.py diff --git a/Assignments/assiagnent6.5.py b/Assignments/assiagnent6.5.py new file mode 100644 index 0000000..f82b884 --- /dev/null +++ b/Assignments/assiagnent6.5.py @@ -0,0 +1,4 @@ +text = "X-DSPAM-Confidence: 0.8475" +x = text.find(' ') +num = text[x+3:] +print num \ No newline at end of file From 75fe481278c72fc1dbb9737312b01a2cea1abe11 Mon Sep 17 00:00:00 2001 From: joojie Date: Thu, 5 May 2016 20:26:59 -0400 Subject: [PATCH 5/8] new --- Assignments/assiagnent5.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Assignments/assiagnent5.py diff --git a/Assignments/assiagnent5.py b/Assignments/assiagnent5.py new file mode 100644 index 0000000..0758582 --- /dev/null +++ b/Assignments/assiagnent5.py @@ -0,0 +1,22 @@ +largest = None +smallest = None +while True: + num = raw_input("Enter a number: ") + if num = "done" : break + try: + num = int(num) + except: + print "not a number" + continue + if largest is none: + largest = value + elif value > largest: + largest = value + continue + elif smallest is none: + smallest = value + elif value < smallest: + smallest = value + continue +print "Maximum", largest +print "minimum", smallest \ No newline at end of file From 204d45b3ea8c6fb524caafd080e1d53dcf12075a Mon Sep 17 00:00:00 2001 From: Sarayaar Date: Mon, 6 Jun 2016 19:59:18 -0700 Subject: [PATCH 6/8] new --- Assignments/assignment 8.4.py | 20 ++++++++++++++++++++ Assignments/assignment4.6.py | 17 +++++++++++++++++ Assignments/assignment7.1.py | 5 +++++ Assignments/assignment7.4.py | 20 ++++++++++++++++++++ Assignments/assignment8.5.py | 21 +++++++++++++++++++++ Assignments/assignment9.4.py | 29 +++++++++++++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 Assignments/assignment 8.4.py create mode 100644 Assignments/assignment4.6.py create mode 100644 Assignments/assignment7.1.py create mode 100644 Assignments/assignment7.4.py create mode 100644 Assignments/assignment8.5.py create mode 100644 Assignments/assignment9.4.py diff --git a/Assignments/assignment 8.4.py b/Assignments/assignment 8.4.py new file mode 100644 index 0000000..f9fe9a8 --- /dev/null +++ b/Assignments/assignment 8.4.py @@ -0,0 +1,20 @@ +fname = raw_input("Enter file name: ") +if len(fname) == 0: + fname == 'romeo.txt' +try: + fh= open(fname) +except: + print "is not file" + +words = [] + +for line in fh: + line_words= line.split() + for word in line_words: + if word in words: + continue + word.appened(word) + +print sorted(words) + + \ No newline at end of file diff --git a/Assignments/assignment4.6.py b/Assignments/assignment4.6.py new file mode 100644 index 0000000..f1148d6 --- /dev/null +++ b/Assignments/assignment4.6.py @@ -0,0 +1,17 @@ +def compute_pay(rate, hours): + try: + rate = float(rate) + hours = float(hours) + except: + print "these need to be numbers" + if hours > 40: + extra_hours = hours - 40 + extra_pay = rate * 1.5 + total = (rate * 40)+ (extra_pay * extra_hours) + return total + else: + total = rate* hours + return total + +p = Compute_pay( 10,20 ) +print p \ No newline at end of file diff --git a/Assignments/assignment7.1.py b/Assignments/assignment7.1.py new file mode 100644 index 0000000..46ff0ec --- /dev/null +++ b/Assignments/assignment7.1.py @@ -0,0 +1,5 @@ +fname = raw_input("Enter file name: ") +fh = open(fname) + +for line in fh: + print line.upper() \ No newline at end of file diff --git a/Assignments/assignment7.4.py b/Assignments/assignment7.4.py new file mode 100644 index 0000000..895999e --- /dev/null +++ b/Assignments/assignment7.4.py @@ -0,0 +1,20 @@ +fname = raw_input("Enter file name: ") + +if len(fname) == 0: + fname == 'mbox-short.txt' + +try: + fh= open(fname) +except: + print "is not file" + +for line in fh: + if not line.startswith('X-DSPAM-Confidence: 0.8475'): + continue + + num_start = line.find('0') + num = line[num_start] + flt = float(num) + count += flt + +print count \ No newline at end of file diff --git a/Assignments/assignment8.5.py b/Assignments/assignment8.5.py new file mode 100644 index 0000000..c3ed6ea --- /dev/null +++ b/Assignments/assignment8.5.py @@ -0,0 +1,21 @@ +fname = raw_input("Enter file name: ") + +if len(fname) == 0: + fname == 'mbox-short.txt' + +try: + fh= open(fname) +except: + print "is not file" + +count = 0 + +for line in fh: + if not line.startswith('from '): + continue + words_list = line.split() + email = words_list[1] + count += 1 + print email + +print count diff --git a/Assignments/assignment9.4.py b/Assignments/assignment9.4.py new file mode 100644 index 0000000..95838d6 --- /dev/null +++ b/Assignments/assignment9.4.py @@ -0,0 +1,29 @@ +name = raw_input("Enter file:") +if len(name) < 1 : name = "mbox-short.txt" + +try: + handle= open(name) +except: + print "is not file" + +emails = {} +email_list =[] + +for line in handle: + if not line.startswith('from '): + continue + email_list = line.split() + email = words[1] + email_list.appened(email) + +for adress in email_list: + email[adress] = emails.get(adress,0)+1 + +big_adress = None +big_number = None + +for adress,count in emails.item(): + if big_count is None or count > big_count: + big_count = count + big_adress= adress +print big_adress,big_count \ No newline at end of file From 4ad8f5f3b34c2de26f2bcbfc331b6a74c732f754 Mon Sep 17 00:00:00 2001 From: Michael McCray Date: Tue, 7 Jun 2016 15:28:36 -0500 Subject: [PATCH 7/8] new --- Assignments/assignment10.2.py | 20 ++++++++++++++++++++ Assignments/assignment11.py | 6 ++++++ Assignments/assignment12.py | 15 +++++++++++++++ Assignments/assignment13.1.py | 7 +++++++ Assignments/assignment13.2.py | 21 +++++++++++++++++++++ Assignments/assignment14.py | 10 ++++++++++ Assignments/assignment15.1.py | 15 +++++++++++++++ 7 files changed, 94 insertions(+) create mode 100644 Assignments/assignment10.2.py create mode 100644 Assignments/assignment11.py create mode 100644 Assignments/assignment12.py create mode 100644 Assignments/assignment13.1.py create mode 100644 Assignments/assignment13.2.py create mode 100644 Assignments/assignment14.py create mode 100644 Assignments/assignment15.1.py diff --git a/Assignments/assignment10.2.py b/Assignments/assignment10.2.py new file mode 100644 index 0000000..3246196 --- /dev/null +++ b/Assignments/assignment10.2.py @@ -0,0 +1,20 @@ +name = raw_input("Enter file:") +if len(name) < 1 : name = "mbox-short.txt" + +try: + handle= open(name) +except: + print "is not file" + +hours = {} + +for line in handle: + if not line.startswith('from '): + continue + hours = line.split() + time = hours [5] + hour = time.split(:) + hours[hour[0]] = hours.get(hour[0], 1) + 1 + +print "\nHours & Counts" +print hours \ No newline at end of file diff --git a/Assignments/assignment11.py b/Assignments/assignment11.py new file mode 100644 index 0000000..cad9942 --- /dev/null +++ b/Assignments/assignment11.py @@ -0,0 +1,6 @@ +import re +numlst=[] +num=re.findall('[0-9]+',http://python-data.dr-chuck.net/regex_sum_242232.txt.read()) +numlst.appened(num) +numlst = int(num) +print sum(numlst) \ No newline at end of file diff --git a/Assignments/assignment12.py b/Assignments/assignment12.py new file mode 100644 index 0000000..96d14d8 --- /dev/null +++ b/Assignments/assignment12.py @@ -0,0 +1,15 @@ +import socket + +socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + +socket.connect(("www.pythonlearn.com",80)) + +socket.send("GET http://www.pythonlearn.com/code/intro-short.txt HTTP/1.0\n\n") + +while True: + data = socket.recv(512) + if (len(data) < 1): + break + print data + +socket.close() \ No newline at end of file diff --git a/Assignments/assignment13.1.py b/Assignments/assignment13.1.py new file mode 100644 index 0000000..13638f5 --- /dev/null +++ b/Assignments/assignment13.1.py @@ -0,0 +1,7 @@ +import urllib +from BeautifulSoup import * +num = [] +for tag in BeautifulSoup(urllib.urlopen('http://python-data.dr-chuck.net/comments_242237.html').read())('span'): + num.append(tag.contents[0]) + int(num) +print sum(num) \ No newline at end of file diff --git a/Assignments/assignment13.2.py b/Assignments/assignment13.2.py new file mode 100644 index 0000000..8ea3147 --- /dev/null +++ b/Assignments/assignment13.2.py @@ -0,0 +1,21 @@ +import urllib +from BeautifulSoup import * + +url = raw_input(" URL: ") +count = raw_input(" count: ") +position = raw_input(" position: ") + +count = int(count) +position = int(position) + +while count > 0: + links = [] + tags = BeautifulSoup(urllib.urlopen(url).read())('a') + + for tag in tags: + links.append(tag.get('href', None)) + + url = links[position-1] + count -= 1 + +print url diff --git a/Assignments/assignment14.py b/Assignments/assignment14.py new file mode 100644 index 0000000..bc0c6ee --- /dev/null +++ b/Assignments/assignment14.py @@ -0,0 +1,10 @@ +import urllib +import xml.etree.ElementTree as ET + +while True: + url = raw_input("Enter URL: ") + if len(url) < 1 : break + total = 0 + for comment in ET.fromstring(urllib.urlopen(url).read()).findall('comments/comment'): + total += int(comment.find('count').text) + print total \ No newline at end of file diff --git a/Assignments/assignment15.1.py b/Assignments/assignment15.1.py new file mode 100644 index 0000000..396a9c7 --- /dev/null +++ b/Assignments/assignment15.1.py @@ -0,0 +1,15 @@ +import urllib +import json + +while True: + url = raw_input('\nEnter location: ') + if len(url) < 1 : break + + print 'Retrieving', url + print '\nRetrieved',len(urllib.urlopen(url).read()),'characters' + print 'Count:', len(json.loads(urllib.urlopen(url).read())['comments']) + + total = 0 + for num in json.loads(urllib.urlopen(url).read())['comments']: + total += int(num['count']) + print 'Sum:', total \ No newline at end of file From bff29d28b4f1364da3bc3bbca2bb3544947655ae Mon Sep 17 00:00:00 2001 From: sonnyali Date: Tue, 7 Jun 2016 19:20:08 -0400 Subject: [PATCH 8/8] new --- Assignments/assignment15.2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Assignments/assignment15.2.py diff --git a/Assignments/assignment15.2.py b/Assignments/assignment15.2.py new file mode 100644 index 0000000..64040c0 --- /dev/null +++ b/Assignments/assignment15.2.py @@ -0,0 +1,17 @@ +import urllib +import json + +url = raw_input('Enter URL: ') + +uh = urllib.urlopen(url).read() + +info = json.loads(uh) + +lst = list() + +for num in info['comments']: + lst.append(int(num['count'])) + +total = sum(lst) + +print 'Sum: ', total