Skip to content

Commit

Permalink
list modified
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed May 3, 2018
2 parents bad46cb + f806fed commit f0a13a7
Show file tree
Hide file tree
Showing 35 changed files with 374 additions and 16 deletions.
13 changes: 13 additions & 0 deletions classes/class1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class student():
name = "rakesh"
website ="binarynote.com"
expertise ="PHP, CSS, HTML,JavaScript,JQuery,WordPress and Now Python Django"

def showMessage(self):
print("This is a demo message from class ")

s = student()

print("Default Behaviour of Class Members in Python\n\n\nName : ",s.name)
print("website : ", s.website)
print("Expertise :", s.expertise,"\n")
22 changes: 22 additions & 0 deletions classes/class2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class student():
name = "rakesh"
website ="binarynote.com"
expertise ="PHP, CSS, HTML,JavaScript,JQuery,WordPress and Now Python Django"

def setData(self,name,web,exp):
self.name = name
self.website = web
self.expertise = exp

def showData(self):
print("Name : ",self.name)
print("website : ", self.website)
print("Expertise :", self.expertise,"\n")

#object creation
s = student()
s.showData()

# set new Data using another function
s.setData("Swarnima", 'swarnima.com','Python, Django, CSS, JavaScript')
s.showData()
21 changes: 21 additions & 0 deletions classes/classConstructor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class student():
name=""
website=""
expertise=""

def __init__(self):
self.name ="swarnima"
self.website = "http://www.swarnima.com"
self.expertise ="Django Specialist"

def showData(self):
print("Name : ",self.name)
print("website : ", self.website)
print("Expertise :", self.expertise,"\n")

#object creation
#

s1 = student() #calling constructor
s1.showData()

14 changes: 14 additions & 0 deletions classes/classDemo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class student:
def read_data(self,name,fatherName,stream):
self.name = name
self.fatherName = fatherName
self.stream = stream

def show_data(self):
print("Student Name ",self.name)
print("father Name ",self.fatherName)
print("Stream Name ",self.stream)

s = student()
s.read_data('rakesh','jagdish','computer')
s.show_data()
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions insert_row.py → database/insert_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
# Licence: MIT
#-------------------------------------------------------------------------------
import MySQLdb

db = MySQLdb.connect("localhost","root","ramji","cable")
cursor = db.cursor();
cursor = db.cursor()
sql ="insert into customer values(20,'rakesh','jagdish','cf-4 arun vihar','12121212','arun@bin.com');"
cursor.execute(sql)
db.close()
Expand Down
6 changes: 0 additions & 6 deletions mysql_connection.py → database/mysql_connection.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@

#-------------------------------------------------------------------------------
import MySQLdb


# Open database connection
db = MySQLdb.connect("localhost","root","ramji","cable" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print("Database version : %s " % data )

# disconnect from server
db.close()
2 changes: 1 addition & 1 deletion select_command.py → database/select_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost","root","ramji","cable" )
cursor = db.cursor();
cursor = db.cursor()
sql ="select * from customer"
cursor.execute(sql)
results = cursor.fetchall()
Expand Down
2 changes: 1 addition & 1 deletion delete All File with extension_EXE.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def main():
root.withdraw()
directory = filedialog.askdirectory() #source folder
count=0
for root,files in os.walk(directory):
for root, SubFolders , files in os.walk(directory):
os.chdir(root)
files = glob.glob('*.exe')
for filename in files:
Expand Down
10 changes: 10 additions & 0 deletions error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sum = 0
for i in range(10):
try:
if 10 / i == 2:
break
except ZeroDivisionError:
sum = sum+1
else:
sum = sum +2
print("Sum :",sum)
2 changes: 1 addition & 1 deletion fileHandling/file_read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file = open(r"C:\Users\acer\Desktop\pythonPrograms\fileHandling\abcd.txt",'r')
file = open(r"C:\Users\acer\Desktop\PythonBox\pythonPrograms\fileHandling\abcd.txt",'r')
data1 = file.read()
print(data1)
file.close()
11 changes: 11 additions & 0 deletions filerenamer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
path = r"C:\Users\acer\Desktop\PythonBox\python_video"
os.chdir(path)
for file in os.listdir():
if os.path.isfile(file):
filename,ext = os.path.splitext(file)
files = filename.split(' ') #now filenames in tuples
newname = files[4] + '-'.join(files[5:])+ext
#print(newname)
os.rename(file,newname)

9 changes: 9 additions & 0 deletions first3char.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def front3(str):
str1 = str[:3]*3
print(str1)

front3('java')
front3('Chocolate')
front3('ab')
front3('a')
front3('')
2 changes: 1 addition & 1 deletion folders_recursivly.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def remove_comment(source):
def compressFile(source):
file = open(source,"r")
file2 = open("temp.dat","w")
data = file.read();
data = file.read()
file2.write(re.sub('[\s]+',' ',data))
file.close()
file2.close()
Expand Down
9 changes: 9 additions & 0 deletions functions/factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def factorial():
n = int(input("Enter any number "))
fact = 1
for i in range(1,n+1):
fact *= i
print("Factorial of ", n ," is :",fact)

#function call
factorial()
9 changes: 9 additions & 0 deletions functions/factorial_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def factorial(n):
fact = 1
for i in range(1,n+1):
fact *= i
print("Factorial of ", n ," is :",fact)

#function call
n = int(input("Enter any number "))
factorial(n)
10 changes: 10 additions & 0 deletions functions/recursive_factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def factorial(n):
if n==1:
return 1
else:
return n*(factorial(n-1))

#function call
n = int(input("Enter any number "))
result = factorial(n)
print("factorial of {} is {} ".format(n,result))
44 changes: 44 additions & 0 deletions gre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from bs4 import BeautifulSoup
from random import randint
import urllib
import pynotify
import time


def sendMessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return

webpage = urllib.urlopen('https://quizlet.com/58647605/kaplan-900-flash-cards').read()

# Parse the entire webpage
soup = BeautifulSoup(webpage)

word = []
meaning = []

# Scrape words from soup
for words in soup.find_all("span", class_="TermText qWord lang-en"):
# Convert ascii to string
word.append(words.text.encode("utf-8"))

# Scrape meanings from soup
for meanings in soup.find_all("span", class_="TermText qDef lang-en"):
meaning.append(meanings.text.encode("utf-8"))

print("Churning words !")


while(1):
index = randint(0,700)
print(index)
# First just pop the word on screen to wait for response
sendMessage(word[index],"")
# Adjust the response time between word and its meaning
time.sleep(15)
# Display the meaning with the word
sendMessage(word[index], meaning[index])
# Time after which a new word pops on screen
time.sleep(600)
3 changes: 3 additions & 0 deletions list_idea.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
list = [1, 1, 2, 3,[5,6], ["anil","Rahul"],5, 8, 13]
print(list[5][0])

Empty file added list_idea1.py
Empty file.
2 changes: 2 additions & 0 deletions multiple_assignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a,b,c = 10,20,30
print("\n Multiple assignment operator \n a = {} \n B = {} \n c= {}".format(a,b,c))
42 changes: 42 additions & 0 deletions newsfeed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
-*- coding: utf-8 -*-
========================
Python Desktop News Notifier
========================
Developed by: Chirag Rathod (Srce Cde)
Email: chiragr83@gmail.com
========================
"""

import feedparser
import notify2
import time
import os


def Parsefeed():
f = feedparser.parse("http://feeds.bbci.co.uk/news/rss.xml")
ICON_PATH = os.getcwd() + "/icon.ico"
notify2.init('News Notify')

for newsitem in f['items']:
print(newsitem['title'])
print(newsitem['summary'])
print('\n')

n = notify2.Notification(newsitem['title'],
newsitem['summary'],
icon=ICON_PATH
)

n.set_urgency(notify2.URGENCY_NORMAL)
n.show()
n.set_timeout(15000)
time.sleep(1200)


if __name__ == '__main__':
try:
Parsefeed()
except:
print("Error")
4 changes: 4 additions & 0 deletions regular/digit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import re
phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d')
mo = phoneNumRegex.search('My number is 415-555-4242.')
print('Phone number found: ' + mo.group())
3 changes: 3 additions & 0 deletions string/reverseString.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
str = "This is original string"
rev = ''.join(reversed(str))
print(rev)
4 changes: 4 additions & 0 deletions string/strConversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pi = 3.14
##text = 'The value of pi is ' + pi ## NO, does not work
text = 'The value of pi is ' + str(pi) ## yes
print(text)
31 changes: 31 additions & 0 deletions string/strFunctions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
str = ''' Python has a built-in string class named "str" with many handy
features (there is an older module named "string" which you
should not use Python. String literals can be enclosed
by either double or single quotes,
although single quotes are more commonly used '''

print("String length :", len(str))
upper = str.upper()
print("String in upper case : ")
print(upper)

lower = upper.lower()
print("\n\nString in lower case :", lower)

strip = str.strip()
print("\n\nString without space at begining and end :", strip)

startwith = str.startswith('python') #return true or fals
endwith = str.endswith('hello')
print(startwith)
print(endwith)

find = str.find('quotes') # display the index of first occurance of the string
print("First appeared at :",find)

newstr = str.replace('Python','c++')
print("\n\n New string where 'Python' was replaced with 'C++' \n", newstr)

split = str.split(' ') # return result in a list
print(split)

6 changes: 6 additions & 0 deletions string/string1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
str = "This is me rakesh"
n = len(str)
print('Length of string is : ',n)
str = str + "Hello rakesh"
print(str)
print(str[0])
6 changes: 3 additions & 3 deletions sum_digit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
a = int(input("Enter any number :")
while a!=0:
a = int(input("Enter any number :"))
sum =0
while (a!=0):
rem = a%10
sum = sum + rem
a = int(a / 10)
Expand Down
10 changes: 10 additions & 0 deletions turtlePrg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
Loading

0 comments on commit f0a13a7

Please sign in to comment.