Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2352998
Merge pull request #1 from The-Knowledge-House/master
glennsvel90 Mar 30, 2016
07cad91
first assignmnet
glennsvel90 Mar 30, 2016
a80f9e8
aggn 2
glennsvel90 Apr 1, 2016
de719cf
Merge pull request #2 from The-Knowledge-House/master
glennsvel90 Apr 6, 2016
e296bfa
Merge pull request #3 from The-Knowledge-House/master
glennsvel90 Apr 12, 2016
dd6e5f2
assignment4.6
glennsvel90 Apr 14, 2016
a05ab07
Merge pull request #4 from The-Knowledge-House/master
glennsvel90 Apr 15, 2016
26597c4
52
glennsvel90 Apr 19, 2016
cbcb17e
hw63
glennsvel90 Apr 21, 2016
d5ede5f
73
glennsvel90 Apr 26, 2016
ee305d8
Merge pull request #5 from The-Knowledge-House/master
glennsvel90 Apr 26, 2016
f3f5a1f
Assignment73
glennsvel90 Apr 26, 2016
eaa3016
my commit
glennsvel90 Apr 26, 2016
0ee2c0f
8.5
glennsvel90 Apr 28, 2016
2465e4c
8.5 homework
glennsvel90 May 4, 2016
c45e4cf
hw 9.4 work
glennsvel90 May 8, 2016
d808b1c
9.4 fixed
glennsvel90 May 8, 2016
5aa67c3
Merge pull request #6 from The-Knowledge-House/master
glennsvel90 May 12, 2016
16dfe8f
10.2 hw
glennsvel90 May 17, 2016
a4a5f2d
11&12
glennsvel90 May 19, 2016
949a080
Merge pull request #7 from The-Knowledge-House/master
glennsvel90 May 19, 2016
66d480c
13.1
glennsvel90 May 19, 2016
16e9213
13s
glennsvel90 May 20, 2016
5c83d5a
Merge pull request #8 from The-Knowledge-House/master
glennsvel90 May 23, 2016
69bdf15
new
glennsvel90 May 24, 2016
19959ee
better
glennsvel90 May 24, 2016
389ea8c
micro
glennsvel90 May 25, 2016
49182ed
Merge pull request #9 from The-Knowledge-House/master
glennsvel90 May 25, 2016
ebecd3e
15s
glennsvel90 May 26, 2016
820bb5a
micro
glennsvel90 May 30, 2016
ee8ef3d
e
glennsvel90 May 30, 2016
5f81858
all
glennsvel90 May 31, 2016
4001105
all4
glennsvel90 May 31, 2016
c037ab3
Merge pull request #10 from The-Knowledge-House/master
glennsvel90 Jun 3, 2016
66a86ef
161
glennsvel90 Jun 11, 2016
fa94120
Merge pull request #11 from The-Knowledge-House/master
glennsvel90 Jun 11, 2016
aa9f60f
16.2
glennsvel90 Jun 11, 2016
b226d4d
17,18
glennsvel90 Jun 15, 2016
2e3b314
prj
glennsvel90 Jun 21, 2016
75f6de5
3 loc
glennsvel90 Jun 21, 2016
9c5fdd8
updated 3
glennsvel90 Jun 21, 2016
31afbbb
7
glennsvel90 Jun 21, 2016
d52993b
7 better
glennsvel90 Jun 21, 2016
55c6ddb
mod
glennsvel90 Jun 22, 2016
24c7f21
project
glennsvel90 Jun 24, 2016
1346b90
projectdo
glennsvel90 Jun 25, 2016
2c8687a
pr
glennsvel90 Jun 26, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added Assignments/Assignment 17_Glenn_Velupillai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Assignments/Assignment10.2_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fname=raw_input("enter file name: ")
fh=open(fname)
purse=dict()
for line in fh:
lst=line.split()
wh=lst[5]
hrlst=wh.split(:)
hr=hrlist[0]

purse(hr)=purse.get(hr,0)+1
t=purse.items()
t.sort()
for k, v in t:
print k,v
13 changes: 13 additions & 0 deletions Assignments/Assignment11_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import re
fname=raw_input("Enter text file: ")
fh=open(fname)
string=fh.read()
numlst=re.findall("[0-9]+",string)
n=list()
for i in numlst:
i=int(i)
n.append(i)

nn=sum(n)

print nn
13 changes: 13 additions & 0 deletions Assignments/Assignment12_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import socket

mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
mysock.connect(("www.pythonlearn.com",80))
mysock.send("GET http://www.pythonlearn.com/code/intro-short.txt HTTP/1.0\n\n")

while True:
data=mysock.recv(512)
if (len(data)<1):
break
print data

mysock.close()
20 changes: 20 additions & 0 deletions Assignments/Assignment13.1_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


import urllib
from BeautifulSoup import *

url=raw_input("Enter - ")
html=urllib.urlopen(url).read()
soup=BeautifulSoup(html)

#using beaurful spoup to ofind all tags with span
numlst = soup('span')
nn = []
#get text in span and convert to integers
for i in numlst:
nn.append(int(i.text))

#summing the number

print sum(nn)

23 changes: 23 additions & 0 deletions Assignments/Assignment13.2_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import urllib
from BeautifulSoup import *

url = raw_input("Enter - ")
count = raw_input("count: ")
position = raw_input("Position: ")

count = int(count)
position = int(position)


while count > 0:

page = urllib.urlopen(url)
soup = BeautifulSoup(page)
anchors = soup('a')

url = anchors[position-1]['href']
count =count- 1

print url


22 changes: 22 additions & 0 deletions Assignments/Assignment14_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import urllib
import xml.etree.ElementTree as ElementTree



lsts=list()
E=raw_input("Enter URL: ")
html= urllib.urlopen(E)




tree=ElementTree.parse(html)

comments=tree.findall('comments/comment')

for comment in comments:
l=comment.find('count').text
n=int(l)
lsts.append(n)

print sum(lsts)
15 changes: 15 additions & 0 deletions Assignments/Assignment15.1_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import urllib
import json

loc=raw_input("Enter location: ")

serviceurl="http://maps.googleapis.com/maps/api/geocode/json?"

url= serviceurl+urllib.urlencode({"senor": "false", "address" : loc})
o=urllib.urlopen(url)

data=o.read()

js=json.loads(str(data))

print "place ID: ", js["results"][0]["place_id"]
16 changes: 16 additions & 0 deletions Assignments/Assignment15.2_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import urllib
import json

url=raw_input("Enter Url: ")
o=urllib.urlopen(url)
r=o.read()
load=json.loads(str(r))

counts=[]
colls=load["comments"]

for coll in colls:
counts.append(coll["count"])

print sum(counts)

Binary file not shown.
1 change: 1 addition & 0 deletions Assignments/Assignment16.1_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
416E6E65726F793137
44 changes: 44 additions & 0 deletions Assignments/Assignment16.2_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import sqlite3
import urllib

conn = sqlite3.connect('emaildb.sqlite')
cur = conn.cursor()

cur.execute('''
DROP TABLE IF EXISTS Counts''')

cur.execute('''
CREATE TABLE Counts (org TEXT, count INTEGER)''')

fname = raw_input('Enter file name: ')
if ( len(fname) < 1 ) : fname = 'http://www.pythonlearn.com/code/mbox.txt'
fh = urllib.urlopen(fname)
for line in fh:
if not line.startswith('From: ') : continue
pieces = line.split()
email = pieces[1]
print email
at_index=email.find('@')
org=email[at_index+1:]
cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
row = cur.fetchone()
if row is None:
cur.execute('''INSERT INTO Counts (org, count)
VALUES ( ?, 1 )''', ( email, ) )
else :
cur.execute('UPDATE Counts SET count=count+1 WHERE org = ?',
(org, ))
# This statement commits outstanding changes to disk each
# time through the loop - the program can be made faster
# by moving the commit so it runs only after the loop completes
conn.commit()

# https://www.sqlite.org/lang_select.html
sqlstr = 'SELECT org, count FROM Counts ORDER BY count DESC LIMIT 10'

print
print "Counts:"
for row in cur.execute(sqlstr) :
print str(row[0]), row[1]

cur.close()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Assignments/Assignment2_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hours = raw_input('Enter hours:')
pay = raw_input('Enter pay rate')

total = float(hours) * float(pay)
print 'Hey I owe you ', total
Binary file not shown.
9 changes: 9 additions & 0 deletions Assignments/Assignment3.1_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hours = raw_input('Enter hours:')
pay = raw_input('Enter pay rate:')

if hours > 40 :
total=((40*float(pay))+(float(hours) - 40)*1.5*float(pay))
else :
total=float(hours)*float(pay)

print 'Hey I owe you ', total
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Assignments/Assignment3.3_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
score=float (raw_input("Enter Score: "))



if score < 0.0:
print "Error, since you entered outside of the range. Please enter score between 0 and 1.0"

if score > 1.0:
print "Error, since you entered outside of the range. Please enter score between 0 and 1.0"

if score < 0.6 and score >=0.0:
print 'Your Letter Grade is: F'



if score >= 0.6 and score < 0.7:
print 'Your Letter Grade is: D'

if score >= 0.7 and score < 0.8:
print 'Your Letter Grade is: C'

if score >= 0.8 and score < 0.9:
print ' Your Letter Grade is: B'

if score >= 0.9 and score <= 1.0:
print ' Your Letter Grade is: A'





Empty file.
19 changes: 19 additions & 0 deletions Assignments/Assignment4.6_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
h = raw_input('Enter hours: ')
r = raw_input('Enter pay rate: ')


def compute(h,r):

try:
h = float(h)
r = float(r)
except:
return "Error, this is not a number"
if h > 40 :
total=((40*r)+(h - 40)*1.5*r)
else :
total=h*r
return "your paycheck is " + str(total)


print compute(h, r)
10 changes: 10 additions & 0 deletions Assignments/Assignment6.5_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

text = "X-DSPAM-Confidence: 0.8475"
# 1 2
# 0123456789012345678901234567890

decimal= text.find(".")
number = float(text[decimal:])
type(number)

print number
20 changes: 20 additions & 0 deletions Assignments/Assignment8.4_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fname = raw_input("Enter file name: ")
fh = open(fname)
lst = list()
word_lst = list()


for line in fh:
#splits all the words and puts it in the list
lst=line.split()
#lowercase the words and if word is not in the VIP "word
# list"
# then add the word to the VIP word list
for word in lst:
word = word.lower()
if word not in word_lst:
word_lst.append(word)

print sorted(word_lst)


15 changes: 15 additions & 0 deletions Assignments/Assignment8.5_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

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
words = line.split()
count = count + 1
print words[1]

print "There were", count, "lines in the file with From as the first word"
25 changes: 25 additions & 0 deletions Assignments/Assignment9.42_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name = raw_input("Enter file:")
if len(name) < 1 :
name = "mbox-short.txt"
handle = open(name)
emails = []

#take away all the spaces before and after the email

for line in handle:
line=line.strip()

#if the line starts with "From "(with space)
if line.startswith('From '):
#splice the email out
s_email = line.find(" ")
e_email = line.find(" ", s_email+1)
emails.append(line[s_email:e_email])
#make a dictionary and add the emails to
#dictionary if not in dictionary, and count emails
counts=dict()
for email in emails:
counts[email] = counts.get(email, 0) + 1

#find the email with the most amounts of counts and print it

23 changes: 23 additions & 0 deletions Assignments/Assignment9.4_Glenn_Velupillai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
fname=raw_input("Enter file name: ")
fh=open(fname)

mlist=list()

for line in fh:
if line.startswith("From: "):
e=line.find(" ")
rest=line[e+1:]
mlist.append(rest)

purse=dict()
for word in mlist:
purse[word]=purse.get(word,0)+1

mcword=None
mccount=None
for word,count in purse.items():
if mccount is None or count > mccount:
mcword=word
mccount=count

print mcword,mccount
Loading