Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/linrakesh/python
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Oct 6, 2019
2 parents bb38c36 + dfc9da9 commit 083aa02
Show file tree
Hide file tree
Showing 28 changed files with 1,054 additions and 42 deletions.
14 changes: 7 additions & 7 deletions DataStructure/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
x =[3,56,2,56,78,56,34,23,4,78,8,123,45]
for i in range(1,len(x)):
for j in range(0,13-i):
if(x[j]>x[j+1]):
x[j],x[j+1] = x[j+1],x[j]
x = [3, 56, 2, 56, 78, 56, 34, 23, 4, 78, 8, 123, 45]
for i in range(1, len(x)):
for j in range(0, 13-i):
if(x[j] > x[j+1]):
x[j], x[j+1] = x[j+1], x[j]

print("Sorted Array :")
print("Sorted Array :")
for i in x:
print(i,end =" ")
print(i, end=" ")
18 changes: 9 additions & 9 deletions DataStructure/insertion_sort.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
x =[3,56,2,56,78,56,34,23,4,78,8,123,45]
for i in range(1,13):
j= i-1
x = [3, 56, 2, 56, 78, 56, 34, 23, 4, 78, 8, 123, 45]
for i in range(1, 13):
j = i-1
temp = x[i]
while(temp<x[j] and j>=0):
x[j+1]=x[j]
while(temp < x[j] and j >= 0):
x[j+1] = x[j]
j = j-1
x[j+1] = temp
print("Sorted Array :")
x[j+1] = temp

print("Sorted Array :")
for i in x:
print(i,end =" ")
print(i, end=" ")
4 changes: 4 additions & 0 deletions DataStructure/merge_python_way.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x =[1,2,3,4,5,6,7,8]
y = [1,2,3,4,5]
z= x+y
print(z)
47 changes: 47 additions & 0 deletions Email/spam_Words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import imapclient # use pip install imapclient <- easy for reading different email Server
import pyzmail # easy to read different part of EMail like subject / body /cc/bcc/to/from etc
from collections import Counter

d=[]
imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True) # email server for Gmail
username=input("Enter your completer gmail User Name ")
Password=input("Enter your gmail passowrd")
imapObj.login(username,Password) # login Method for your email
print("Dear", username," you are logged into your account")
imapObj.select_folder('[Gmail]/Spam', readonly=True) # selecting different folder for phising email i used Spam
UIDs = imapObj.search(['ALL']) # different filter for mailboxes ALL/SEEN/UNSEEN it returns ids for the filter you have search
print( "No of emails in your [Gmail]/Spam' box=" ,len(UIDs))
print("Mail from\t\t"," Subject Line")
for i in UIDs: # only 10 emails to be taken
rawMessages = imapObj.fetch([i], ['BODY[]', 'FLAGS']) # fetch the email message for particular UID
message = pyzmail.PyzMessage.factory(rawMessages[i][b'BODY[]']) # Parse the raw email message.
print(message.get_addresses('from'),message.get_subject()) # return the subject part of email
message.text_part != None # check for text part of body message Message can have html part also
d.append(message.text_part.get_payload().decode(message.text_part.charset)+"\n") # fetch the textpart
#get_payload() method that returns the email’s body as a value of the bytes data type But this still isn’t a string value that we can use.
#decode() method takes one argument: the message’s character encoding,
#stored in the text_part.charset or html_part.charset attribute. This, finally, will return the string of the email’s body.
imapObj.logout()
print("Logged out successfully from server...")

with open("E:\email2.txt", 'w') as fp:
for i in range(len(d)):
fp.write(str(d[i]))


file = open("E:\email2.txt")
split_it=[]
for line in file:
line=line.strip()
split_it+=line.split() # split() returns list of all the words in the string


# Pass the split_it list to instance of Counter class.
Counter = Counter(split_it)
# most_common() produces k frequently encountered
# input values and their respective counts.
print( "most common word found in EMails")
num=int(input("How many most common words you want to find"))
most_occur = Counter.most_common(num)
for com in most_occur:
print(com[0],"=>",com[1])
16 changes: 16 additions & 0 deletions Loops/anagram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# program to find out all anagram of given word
# made by : rakesh kumar

from itertools import permutations

def words(letters):
yield from map(''.join, permutations(letters, len(letters)))

result = set()
for word in words('Compute'):
result.add(word)

print(f' There are {len(result)} combinations')
print(result)


3 changes: 3 additions & 0 deletions Loops/if_python_way.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x = 1
result = "found" if x == 1 else "not found"
print(result)
2 changes: 1 addition & 1 deletion Text_Speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os

# The text that you want to convert to audio
mytext = 'My Baby samraddhi is playing with my mobile phone. Welcome to binarynote.com and this is really amazing my dear!'
mytext = 'My Baby samraddhi is playing with my mobile phone.Amazing my dear!'

# Language in which you want to convert
language = 'en'
Expand Down
2 changes: 1 addition & 1 deletion add.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
d= 10
a= a+2
b = b-20
a= c-30
a= b-30
print(a)
46 changes: 26 additions & 20 deletions database/database_complete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#-------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
Expand All @@ -7,50 +7,56 @@
# Created: 12-04-2018
# Copyright: (c) acer 2018
# Licence: <your licence>
#-------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

import MySQLdb


def show_records():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
sql ="select * from customer"
sql = "select * from customer"
cursor.execute(sql)
results = cursor.fetchall()
for idr,name,fname,add,phone,email in results:
print(idr,name,fname,phone,email)
for idr, name, fname, add, phone, email in results:
print(idr, name, fname, phone, email)
db.close()


def del_record():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
name = input("Enter name you want to delete")
sql ="delete from customer where name like '%" + name +"'%"
sql = "delete from customer where name like '%" + name + "'%"
cursor.execute(sql)
db.commit();
db.close();
db.commit()
db.close()
print("Record Deleted successfully")


def update_record():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
email = input("Admin ID :")
sql ="update customer set email = '[email protected] where email like '%" + email +"'%"
sql = "update customer set email = '[email protected] where email like '%" + email + "'%"
cursor.execute(sql)
db.commit();
db.close();
db.commit()
db.close()
print("Record Updated successfully")


def main():
n=1
while n!=4:
n = 1
while n != 4:
n = int(input("Enter any no (1..3) "))
print(n)
if n==1:
if n == 1:
show_records()
if next==2:
if next == 2:
del_record()
if next==3:
if next == 3:
update_record()


if __name__ == '__main__':
main()
main()
Loading

0 comments on commit 083aa02

Please sign in to comment.