This file contains hidden or 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
""" Script for Tkinter GUI chat client. """ | |
import tkinter | |
from socket import AF_INET, socket, SOCK_STREAM, gethostbyname, gethostname | |
from threading import Thread | |
import math | |
import subprocess as sp | |
def receive(): | |
""" Handles receiving of messages. """ | |
while True: |
This file contains hidden or 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 math import log, floor | |
def dec_to_bin(N): | |
if N == 0 or N == 1: | |
return N | |
String = '' | |
Powers = [] | |
while N > 0: | |
x = log(N, 2) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
''' | |
Write a Python script to search for text in a file and replace it, for example, there is a text file that reads Hello World, change it to Hello name. The intended output is the link to the gist. | |
''' | |
fName = input("Enter the file's name: ") | |
with open(fName) as f: | |
data = f.read() | |
repl = input("Enter the text to be replaced: ") | |
word = input(f"Replace {repl} to: ") |
This file contains hidden or 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 | |
print("Python Program to print list the files in a directory.") | |
Direc = input(r"Enter the path of the folder: ") | |
print(f"Files in the directory: {Direc}") | |
files = os.listdir(Direc) | |
files = [f for f in files if os.path.isfile(Direc+'/'+f)] #Filtering only the files. | |
print(*files, sep="\n") |
This file contains hidden or 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 PIL import Image, ImageDraw, ImageFont | |
import os | |
Class = input("Enter Class In Roman Numerals: ") | |
Class = Class.upper.strip() | |
section = input("Section:") | |
os.chdir('{0}{1}'.format(Class, section)) | |
files = os.listdir(os.getcwd()) #Listing All The Files | |
#Selecting Only JPEG Files ... |
This file contains hidden or 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 subprocess as sp | |
import omdb | |
import wikipedia | |
import wolframalpha | |
import serial | |
import time | |
ser = serial.Serial('COM3', baudrate = 9600, timeout=1) | |
time.sleep(3) | |
def getValues(): | |
ser.write(b'g') |
This file contains hidden or 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 __future__ import print_function, division, unicode_literals | |
import os | |
import errno | |
from collections import Counter | |
from hashlib import sha256 | |
import re | |
import json | |
import itertools | |
import logging |
This file contains hidden or 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 nltk.classify import NaiveBayesClassifier | |
from nltk.corpus import subjectivity | |
from nltk.sentiment import SentimentAnalyzer | |
from nltk.sentiment.util import * | |
from nltk.sentiment.vader import SentimentIntensityAnalyzer | |
import nltk, re | |
class Polarity: | |
def __init__(self): |
This file contains hidden or 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 code was tested and working on python 3.6.5 | |
#The Module TextBlob Needs To Be Installed as it contains a predefined function that | |
#can calculate the polarities. It includes a list of words that has a list of certain value .. | |
from textblob import TextBlob | |
text = input("Enter The Text> ") | |
model = TextBlob(text) | |
print(model.sentiment.polarity) | |
#The Polarity ranges from -1 to 1 |