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
def convert_si_to_number(x): | |
total_stars = 0 | |
if 'k' in x: | |
if len(x) > 1: | |
total_stars = float(x.replace('k', '')) * 1000 # convert k to a thousand | |
elif 'M' in x: | |
if len(x) > 1: | |
total_stars = float(x.replace('M', '')) * 1000000 # convert M to a million | |
elif 'B' in x: | |
total_stars = float(x.replace('B', '')) * 1000000000 # convert B to a Billion |
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
import requests | |
import time | |
imageUrl = 'https://images.unsplash.com/photo-1558981396-5fcf84bdf14d' | |
image = requests.get(imageUrl) | |
imageBytes = image.content | |
fileName = imageUrl.split('/')[3] + '.png' #getting photo name from the url |
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
import requests | |
import time | |
imageUrls = ['https://images.unsplash.com/photo-1558981396-5fcf84bdf14d', | |
'https://images.unsplash.com/photo-1583314059352-663691cfa23f', | |
'https://images.unsplash.com/photo-1583314238585-21664bba94ab', | |
'https://images.unsplash.com/photo-1583317094917-8aac805fed5a' , | |
'https://images.unsplash.com/photo-1583307266943-e0055bb40037' ] | |
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
from gtts import gTTS | |
import os | |
message = 'Hello Asad!' | |
output = gTTS(text = message, lang= 'en', slow = False) | |
output.save('sayHello.mp3') | |
os.system('start sayHello.mp3') |
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
from gtts import gTTS | |
import os | |
with open('message.txt') as file: | |
message = file.read() | |
output = gTTS(text = message, lang = 'hi', slow = False) | |
output.save('messageFromFile.mp3') |
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
from PyPDF2 import PdfFileReader | |
with open('Sommerville-Software-Engineering-10ed.pdf', 'rb') as pdf: | |
pdfReader = PdfFileReader(pdf) | |
page = pdfReader.getPage(0) | |
pageText = page.extractText() |
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
from PyPDF2 import PdfFileReader | |
fileName = '' #Enter the name of pdf file here | |
with open(fileName + '.pdf', 'rb') as pdf: | |
pdfReader = PdfFileReader(pdf) | |
totalPages = pdfReader.numPages |
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
spamMessage = {'million': 156, 'dollars': 29, 'adclick': 51, 'conferences': 2} | |
hamMessage = {'million': 98, 'dollars': 119, 'adclick': 1, 'conferences': 12} | |
spamWordCount = 95791 | |
hamWordCount = 306438 | |
probabilitySpam = 0.00 | |
probabilityHam = 0.00 | |
def likelihood(word): |
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
import sounddevice as sound | |
from scipy.io.wavfile import write | |
duration = 5 | |
sampleRate = 4100 | |
sound.default.samplerate = sampleRate | |
sound.default.channels = 2 |
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
import os | |
def searchFile(requiredFile): | |
if requiredFile in os.listdir(): | |
return True | |
else: |
OlderNewer