Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Dineshkarthik/0001/activation_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0001 Title: As Apple Store App independent developer, you engage in limited-time promotion for your application to generate activation code (or coupon), how to use Python to generate 200 activation code (or coupon)?

import uuid

def act_code(count):
f = open('code.txt', 'wb')
for i in range(count):
s = str(uuid.uuid4().get_hex().lower()[0:8])
f.write(''.join(s) + '\n')
f.close()

if __name__ == '__main__':
act_code(200)
17 changes: 17 additions & 0 deletions Dineshkarthik/0003/0003.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0003 Title: The 0001 title generated 200 activation code (or coupon) to save Redis non-relational databases.

from walrus import *

def redis_store(count):
db=Database(host='localhost',port=6379,db=0)
h = db.List("activation_code")
for i in range(count):
s = str(uuid.uuid4().get_hex().lower()[0:8])
h.extend([s])

if __name__ == '__main__':
redis_store(200)
27 changes: 27 additions & 0 deletions Dineshkarthik/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0004 Title: any of a plain text file in English, statistics on the number of words appears.

import pandas as pd
import re

def word_count(file_path):
word_string = [line.rstrip('\n') for line in open(file_path)]
words = []
for word in word_string:
tt = word.lower()
t=re.sub(r'[^\w]', ' ', tt)
for word in t.split():
words.append(word)

p = pd.Series(words)
#get the counts per word
freq = p.value_counts()
#how many max words do we want to give back
freq = freq.ix[0:25]
print freq
if __name__ == '__main__':
word_count("input.txt")

9 changes: 9 additions & 0 deletions Dineshkarthik/0004/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Python Workbook, a small daily program

Explanation:

Python Workbook, a small daily program. Note: Python into other languages, most of the topics also apply
Do not appear, such as "print multiplication table", "Print Narcissus" like topic
In this paper, the history of this paper by the @ Jiang Song ( shijiangge@gmail.com QQ: 499 065 469) according to organize data collection from the Internet, thanks to the Internet, thanks for sharing. Thanks! This article will be updated continuously.
Welcome to the Pull Request a problem, paste the code (Gist, Blog can be) :-)
Welcome to answer, and send pull request to the Show-Me-the-Code
35 changes: 35 additions & 0 deletions Dineshkarthik/0006/0006.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0006 title: Do you have a catalog, you put a month's diary, they are txt, word in order to avoid the problem, assuming that the content is in English, see the statistics of each diary you think the most important word.

import re
import pandas as pd
import glob
import fnmatch
import os

def word_count(file_path):
data = []
for root, dirnames, filenames in os.walk(file_path):
for filename in fnmatch.filter(filenames, '/*.txt'):
data.append([line.rstrip('\n') for line in open(os.path.join(root, filename))])
word_string = ["".join(str(x) for x in data)]
words = []
ignore_words = ["omitted", "media","a","able","about","above","abst","accordance","according","accordingly","across","act","actually","added","adj","affected","affecting","affects","after","afterwards","again","against","ah","airport","alarm","alive","all","almost","alone","along","already","also","although","always","am","among","amongst","an","and","angry","announce","another","answer","any","anybody","anyhow","anymore","anyone","anything","anyway","anyways","anywhere","apart","app","apparently","application","approximately","are","aren","arent","arise","arm","around","as","aside","ask","asking","at","auth","available","away","awfully","b","back","bad","bag","bake","bar","be","became","because","become","becomes","becoming","been","beer","before","beforehand","begin","beginning","beginnings","begins","behind","being","believe","bell","below","bend","beside","besides","between","beyond","bike","bill","biol","bite","boose","boss","both","brief","brief","briefly","bro","buddy","busy","but","button","by","c","ca","calculate","calculated","call","called","calm","came","can","can't","cannot","cat","cause","causes","certain","certainly","chat","chair","channel","check","close","closing","clue","co","code","coffee","com","come","comes","company","complete","completed","congrats","contain","containing","contains","could","couldnt","cow","crash","cross","d","da","dai","data","database","date","daughter","day","db","delete","deleted","desk","did","didn't","diet","different","dinner","do","does","doesn't","dog","doing","don't","done","down","downwards","drive","dude","due","during","e-mail","e","each","ear","ear","ears","ease","east","easy","ed","edu","effect","eg","eh","eight","eighty","either","else","elsewhere","email","emp","empty","end","ending","enough","error","especially","et-al","et","etc","even","evening","ever","every","everybody","everyone","everything","everywhere","ex","except","exciting","eye","eyes","f","far","fault","female","few","ff","fifth","file","first","five","fix","flower","fly","followed","following","follows","food","for","former","formerly","forth","found","four","friday","friend","from","fuck","fun","funny","further","furthermore","g","garbage","gate","gave","gb","get","gets","getting","girl","git","give","given","gives","giving","glove","go","god","goes","gone","good","got","gotten","great","gross","guy","h","ha","had","hair","hall","happens","hardly","has","hasn't","hate","have","haven't","having","he","hed","hello","hence","her","here","hereafter","hereby","herein","heres","hereupon","hers","herself","hes","hi","hid","high","him","himself","his","hither","ho","holy","home","hope","how","howbeit","however","hundred","husband","i","i'll","i've","id","ie","if","im","image","immediate","immediately","importance","important","in","inc","increase","increased","indeed","index","information","instead","into","invention","inward","iron","is","isn't","it","it'll","itd","its","itself","j","junior","just","k","keep","keeps","kept","kg","kid","kids","km","know","known","knows","l","largely","last","lately","later","latter","latterly","laugh","least","leave","leg","legs","less","lest","let","lets","life","like","liked","likely","line","list","little","ll","load","lol","look","looking","looks","lost","loud","love","low","ltd","lucky","lunch","m","ma'am","maam","madam","made","mail","mainmainly","make","makes","male","mam","many","marry","matemay","maybe","mb","me","meal","meals","mean","means","meantime","meanwhile","men","menu","merely","message","mg","might","million","mineral","miss","ml","mobile","monday","monthly","more","moreover","morning","most","mostly","move","movie","mr","mrs","much","mug","must","my","myself","n","na","name","named","namely","nay","nd","near","nearly","necessarily","necessary","need","needs","neither","never","nevertheless","new","next","nine","ninety","no","nobody","noise","non","none","nonetheless","noone","nor","normally","north","nos","not","noted","nothing","now","nowhere","np","o","obtain","obtained","obviously","of","off","offer","often","oh","ok","okay","old","omitted","on","once","one","ones","only","onto","open","opening","or","ord","other","others","otherwise","ought","our","ours","ourselves","out","outside","over","overall","owing","own","p","page","pages","part","particular","particularly","past","pattern","pause","pay","pays","pencil","per","perhaps","phone","photo","picture","ping","placed","play","please","pls","plus","pong","poorly","possible","possibly","potentially","pp","predominantly","present","previously","primarily","pro","probably","promise","promptly","proof","proud","provides","pull","push","put","q","que","quickly","quiet","quit","quite","qv","r","ran","rather","ratio","rd","re","readily","really","recent","recently","ref","refs","regarding","regardless","regards","related","relatively","reload","reply","research","respectively","restraunt","resulted","resulting","results","right","rock","rofl","roll","run","s","said","same","saturday","saw","say","saying","says","script","sec","section","see","seeing","seem","seemed","seeming","seems","seen","self","selves","send","senior","sent","sent","seven","several","shall","she","she'll","shed","shes","shit","shock","should","shouldn't","show","showed","shown","showns","shows","shut","significant","significantly","similar","similarly","since","sir","sirr","six","slightly","slip","smoke","so","some","somebody","somehow","someone","somethan","something","sometime","sometimes","somewhat","somewhere","son","song","soon","sorry","sort","sound","south","specifically","specified","specify","specifying","sport","sports","still","stop","story","strongly","sub","substantially","successfully","such","sufficiently","suggest","sunday","sup","super","superb","sure","take","taken","taking","tall","tea","team","tear","tell","temporary","tends","term","test","text","th","than","thank","thanks","thanx","that","that'll","that've","thats","the","their","theirs","them","themselves","then","thence","there","there'll","there've","thereafter","thereby","thered","therefore","therein","thereof","therere","theres","thereto","thereupon","these","they","they'll","they've","theyd","theyre","thing","think","this","those","thou","though","thoughh","thousand","throat","throug","through","throughout","thru","thursday","thus","tight","til","till","time","tiny","tip","to","today","toe","together","too","took","tooth","toward","towards","tower","town","translate","tried","tries","truck","truly","trust","try","trying","ts","tuesday","twice","two","u","un","under","unfair","unfortunately","unless","unlike","unlikely","until","unto","up","update","updated","upon","upper","ups","us","use","used","useful","usefully","usefulness","user","uses","using","usually","v","value","various","ve","very","via","visible","viz","vol","vols","volume","vs","w","wake","want","wants","was","wash","wasnt","way","we","we'll","we've","web","website","wed","wednesday","weekend","weekly","welcome","went","were","werent","west","what","what'll","whatever","whats","when","whence","whenever","where","whereafter","whereas","whereby","wherein","wheres","whereupon","wherever","whether","which","while","whim","whither","who","who'll","whod","whoever","whole","whom","whomever","whos","whose","why","widely","wife","will","willing","wish","with","within","without","women","wont","words","work","works","world","would","wouldnt","wrap","wtf","www","x","y","ya","yeah","yep","yes","yesterday","yet","you","you'll","you've","youd","your","youre","yours","yourself","yourselves","youth","z","zero","things","testing","nice","working","messages","issues","issue","refresh","users","upload","download","view","free","kool","uh","duh","join","joining","original","alright","large","entire","start","month","sense","fill"]
for word in word_string:
tt = word.lower()
t=re.sub(r'[^\w]', ' ', tt)
for word in t.split():
if word not in ignore_words:
words.append(word)

p = pd.Series(words)
#get the counts per word
freq = p.value_counts()
#how many max words do we want to give back
freq = freq.ix[0:25]
print freq
if __name__ == '__main__':
word_count("/MyDairy")
9 changes: 9 additions & 0 deletions Dineshkarthik/0006/MyDairy/day1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Python Workbook, a small daily program

Explanation:

Python Workbook, a small daily program. Note: Python into other languages, most of the topics also apply
Do not appear, such as "print multiplication table", "Print Narcissus" like topic
In this paper, the history of this paper by the @ Jiang Song ( shijiangge@gmail.com QQ: 499 065 469) according to organize data collection from the Internet, thanks to the Internet, thanks for sharing. Thanks! This article will be updated continuously.
Welcome to the Pull Request a problem, paste the code (Gist, Blog can be) :-)
Welcome to answer, and send pull request to the Show-Me-the-Code
2 changes: 2 additions & 0 deletions Dineshkarthik/0006/MyDairy/day2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To change the file object’s position, use f.seek(offset, from_what). The position is computed from adding offset to a reference point; the reference point is selected by the from_what argument.
A from_what value of 0 measures from the beginning of the file, 1 uses the current file position, and 2 uses the end of the file as the reference point. from_what can be omitted and defaults to 0, using the beginning of the file as the reference point.
1 change: 1 addition & 0 deletions Dineshkarthik/0006/MyDairy/day3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In text files (those opened without a b in the mode string), only seeks relative to the beginning of the file are allowed (the exception being seeking to the very file end with seek(0, 2)) and the only valid offset values are those returned from the f.tell(), or zero. Any other offset value produces undefined behaviour.
15 changes: 15 additions & 0 deletions Dineshkarthik/0008/0008.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0008 Title: an HTML file, find the inside of the body .


import urllib2
from bs4 import BeautifulSoup

url = "https://www.google.co.in"
page = urllib2.urlopen(url)

soup = BeautifulSoup(page)
print soup.body.text
17 changes: 17 additions & 0 deletions Dineshkarthik/0009/0009.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/local/bin/python
#coding=utf-8
__author__ = 'Dineshkarthik'

#0008 Title: an HTML file, find the inside of the link .


import urllib2
from bs4 import BeautifulSoup

url = "https://www.google.com"
page = urllib2.urlopen(url)

soup = BeautifulSoup(page)
links = soup.findAll('a')
for link in links:
print(link['href'])