-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/linrakesh/python
- Loading branch information
Showing
28 changed files
with
1,054 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
d= 10 | ||
a= a+2 | ||
b = b-20 | ||
a= c-30 | ||
a= b-30 | ||
print(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#------------------------------------------------------------------------------- | ||
# ------------------------------------------------------------------------------- | ||
# Name: module1 | ||
# Purpose: | ||
# | ||
|
@@ -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() |
Oops, something went wrong.