Found 10400 Articles for Python

Text Analysis in Python3

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

265 Views

In this assignment we work with files. Files are everywhere in this Universe. In computer system files are essential part. Operating system consists a lot of files. Python has two types of files-Text Files and Binary Files. Here we discuss about Text Files Here we focus some of the important functions on files. Number of words Number of characters Average word length Number of stop words Number of special characters Number of numeric Number of uppercase words We have a test file "css3.txt", we are working on that file Number of words When we count number of ... Read More

Morse Code Translator in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

3K+ Views

Morse Code Translator is used in Cryptography. It is named by Samuel F. B. Morse. By this technique we convert a message to a series of dots, commas, "-", "/". This technique is very simple. Every alphabet in English signifies a series of ".", ", ", "/", "-". We just encrypt the message from message to symbols and decrypt from symbols to English. The dictionary is given below 'A':'.-', 'B':'-...', 'C':'-.-.', 'D':'-..', 'E':'.', 'F':'..-.', 'G':'--.', 'H':'....', 'I':'..', 'J':'.---', 'K':'-.-', 'L':'.-..', 'M':'--', 'N':'-.', 'O':'---', 'P':'.--.', 'Q':'--.-', 'R':'.-.', 'S':'...', 'T':'-', 'U':'..-', 'V':'...-', 'W':'.--', 'X':'-..-', 'Y':'-.--', 'Z':'--..', '1':'.----', '2':'..---', '3':'...--', '4':'....-', '5':'.....', ... Read More

Using CX_Freeze in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

997 Views

Sometimes we feel to create something different which is very exciting, and according to human nature, we always love to share it. Python also fulfills those wishes. Using Python, if we want to share our Python program with our friends we can do that, only need to have the same version of Python installed with all the modules those are used in program of their machine. First we need to install CX_Freeze module using pip install CX_Frezze command in command prompt. First step is to solve this assignment, a python program conversion. We need standard library modules, here we ... Read More

Multiprocessing In Python

Samual Sam
Updated on 26-Jun-2020 12:43:27

5K+ Views

The multiprocessing package supports spawning processes. It refers to a function that loads and executes a new child processes. For the child to terminate or to continue executing concurrent computing, then the current process hasto wait using an API, which is similar to threading module.IntroductionWhen we work with Multiprocessing, at first we create process object. Then it calls a start() method.Example codefrom multiprocessing import Process    def display():       print ('Hi !! I am Python')       if __name__ == '__main__':       p = Process(target=display)       p.start()       p.join()In this example, ... Read More

Tweet using Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

177 Views

Before using Tweet in Python, we have to follow some steps. Step1 − at first we must have a tweeter profile and then it has to be added with our mobile number. First go to - Settings -> Add Phone -> Add number -> Confirm -> Save. We have to follow these steps. Then turn off all text notifications. Step2 − Set up a new app. Follow − Twitter Apps -> Create New App -> Leave Callback URL empty -> Create Twitter application. Then display message "Your application has been created. You review and adjust your application's settings". Step3 − ... Read More

Synchronization and Pooling of processes in Python

Samual Sam
Updated on 26-Jun-2020 12:44:50

714 Views

Synchronization between processesMultiprocessing is a package which supports spawning processes using an API. This package is used for both local and remote concurrencies. Using this module, programmer can use multiple processors on a given machine. It runs on Windows and UNIX os.All equivalent synchronization primitives are present in this package.Example codefrom multiprocessing import Process, Lock    def my_function(x, y):       x.acquire()       print ('hello world', y)       x.release()       if __name__ == '__main__':       lock = Lock()    for num in range(10): Process(target= my_function, args=(lock, num)).start()Here one instance can lock ... Read More

Plotting solar image in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

338 Views

In Python provides SunPy package for create solar image. In this package has different files which are solar data of proton/electron fluxes from various solar observatory and solar labs. Using pip install sunpy command, we can install sunpy package. Here we plot a sample AIA image. AIA is Atmospheric Imaging Assembly. This is another instrument board of the SDO. Here we use sunpy.Map() function to create a map from one of the supported data products. Example code import sunpy.map import matplotlib.pyplot as plt import sunpy.data.sample my_aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE) fig = plt.figure() ax = plt.subplot(111, projection=my_aia) my_aia.plot() my_aia.draw_limb() ... Read More

Scraping and Finding Ordered Word in a Dictionary in Python

karthikeya Boyini
Updated on 26-Jun-2020 12:37:10

650 Views

For solving this problem we need requests module.For installing requests module, we need this command to get executed at command line.pip install requestsScrapingImport requests module.Then we need to fetch data from URL.Using UTF-8 decode the text.Then convert string into a list of words.Ordered FindingTraverse the list of words using loop.Then compare the ASCII value of adjacent character of each word.If the comparison is true then print ordered word otherwise store the unordered word.Example codeimport requests    def Words_find():       my_url = ""#put thisurl of .txt files in any website       my_fetchData = requests.get(my_url)       ... Read More

Underscore(_) in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

625 Views

In Python in some cases we use Single Underscore(_) and some cases we use Double Underscores (__). In Python has following cases, where we use underscore. If we want to store the value of last expression in interpreter. If we want to ignore some values. For declaration of variable or function. To separate digits of number lateral value. It is also used as ‘Internationalization (i18n)’ or ‘Localization (l10n)’ functions. Now some examples on every cases. Used in interpreter The Python Interpreter stores the last expression value in the '_'. >>> 20 20 >>> _ ... Read More

JSON Formatting in Python

Samual Sam
Updated on 26-Jun-2020 12:26:45

9K+ Views

The JSON (Java Script Object Notation) is light weight, well accepted data interchange format. Using JSON formatting techniques in Python, we can convert JSON strings to Python objects, and also convert Python Objects to JSON strings.To use these functionalities, we need to use the json module of Python. The json module comes with the Python standard library. So at first we have to import it first.import jsonConverting Python objects to JSON StringIn the json module, there are some methods like dump(), and dumps() to convert Python objects to JSON strings. The dump() method takes two arguments, the first one is ... Read More

Advertisements