Skip to content

Commit

Permalink
string and list programs
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Aug 26, 2019
1 parent 2e50619 commit f4de026
Show file tree
Hide file tree
Showing 21 changed files with 933 additions and 21 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=" ")
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
4 changes: 2 additions & 2 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,7 +7,7 @@
# Created: 12-04-2018
# Copyright: (c) acer 2018
# Licence: <your licence>
#-------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

import MySQLdb

Expand Down
735 changes: 735 additions & 0 deletions examveda.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion fileHandling/delete All File with extension_EXE.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
for root, SubFolders , files in os.walk(directory):
os.chdir(root)
files = glob.glob('*.exe')
print(files)
# print(files)
for filename in files:
os.unlink(filename)
count+=1
Expand Down
13 changes: 13 additions & 0 deletions list/frequency_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 3, 2, 4, 2, 1, 5, 6, 7, 2, 3, 4, 1]

num = []
freq = []

for i in list1:
if i not in num:
num.append(i)
count = list1.count(i)
freq.append(count)

for i in range(len(num)):
print(num[i], 'appear', freq[i], 'times')
14 changes: 14 additions & 0 deletions list/frequency_table_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
''' program to find out frequency of each element in a list using dictionary
made by : rakesh kumar
last compiled on : 10-08-2018
'''

list1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 3, 2, 4, 2, 1, 5, 6, 7, 2, 3, 4, 1]
freq = {}
for i in list1:
if i not in freq:
count = list1.count(i)
freq[i] = count

for i in freq:
print(i, 'appear', freq[i], 'times')
13 changes: 13 additions & 0 deletions list/unique_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
''' program to find out unique element in a list
made by : rakesh kumar
last compiled on : 10-08-2018
'''

list1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 3, 2, 4, 2, 1, 5, 6, 7, 2, 3, 4, 1]
num = []
for i in list1:
if i not in num:
num.append(i)

for i in num:
print(i)
17 changes: 17 additions & 0 deletions list/user_generated_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
''' program to create a user generated list and then find out largest and lowest element
made by : rakesh kumar
last modified : 20-auguest-2018 '''

number = []
while True:
x = int(input('Enter any number :'))
if x == 0:
break
number.append(x)

largest = max(number)
lowest = min(number)

print("\n\n")
print("largest Number :", largest)
print("Lowest Number :", lowest)
Empty file added numpy/intro1-.py
Empty file.
7 changes: 7 additions & 0 deletions string/count_chars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
string = input("Enter any string :")
count =0
for i in string:
count = count+1

print("Total Chars :",count)

7 changes: 7 additions & 0 deletions string/count_chars_using _len_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
string = '''Dear Parents
This is to inform you that C.B.S.E is organizing a four day capacity building program in our school from 27 august to 30th august 2019 and DAVCAE is organizing performance enhancement program on 31st august 2019. As the principal & the teachers will remain busy during these 5 days, they shall not be able to address your problem. Therefore you are requested not to visit the school on these mentioned dates and face inconvenience.
However the fee counter will remain open for transactions if any. Looking forward to your continued support and co-operation
Regards
Archana Koul'''

print(len(string))
5 changes: 5 additions & 0 deletions string/reverse_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
string =input("Enter any string :")

n = len(string)
for i in range(n-1,-1,-1):
print(string[i],end='')
19 changes: 19 additions & 0 deletions string/search_char_without_function-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
''' program to search a char from a string
made by : rakesh
last edited : 26-aug-2019
'''

string = "umbrella"
char = 'e'

jatin =9010

for i in string:
if char ==i:
jatin = 1010


if(jatin==1010):
print("found")
else:
print("not found")
7 changes: 7 additions & 0 deletions string/search_char_without_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
string = "umbrella"
char = 'e'

if char in string:
print("Available")
else:
print("not available")
41 changes: 41 additions & 0 deletions string/substring_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
''' program to find out substring in a given substring
made by : rakesh kumar
last editted : 26-auguest 2019 '''

string = "this is orange juice"
sub = 'orange'

# method -1
# if sub in string:
# print("present")
# else:
# print("non present")

#method - 2

# found = string.find(sub)
# if(found != -1):
# print("found")
# else:
# print("not found")

# method -3
# if sub in string.split():
# print("found")
# else:
# print("not found")

# method -4
# count = string.count(sub)
# if(count != 0):
# print("found")
# else:
# print("not found")

#method - 5

# result = "found" if sub in string else "not found"
# print(result)

#method -6
print("found" if sub in string else "not found")
30 changes: 30 additions & 0 deletions webscraper/examveda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import requests
from bs4 import BeautifulSoup

source = requests.get("https://www.examveda.com/commerce/practice-mcq-question-on-accounting/?page=2",'lxml').text
soup = BeautifulSoup(source,'lxml')
#print(soup.prettify())

for article in soup.find_all('article',class_='question single-question question-type-normal'):
try:
question_no = article.find('div', class_="question-number")
question = article.find('div', class_="question-main").text
parts = article.find('div', class_="question-options")
answer = article.find('span', class_="color").text
answer_content = article.find('div', class_="page-content")
answer_key = answer_content.find('strong').text
#print(answer_content.prettify())
solution = article.find('span').text

print(question_no.text, question)
parts = article.find('div', class_="question-options")
i = 1
for option in parts.find_all('label'):
if(i % 2 == 0):
print(option.text)
i = i+1
print(answer, answer_key)

except:
pass

3 changes: 2 additions & 1 deletion webscraper/youtubeDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# import shutil
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=N5vscPTWKOk'])
ydl.download(
['https://www.facebook.com/111437890200079/videos/2399259550150228/'])
Binary file modified welcome.mp3
Binary file not shown.

0 comments on commit f4de026

Please sign in to comment.