
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

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

186 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

813 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

360 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

673 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

661 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

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

1K+ Views
Using Python, we can easily convert data into different types. There are different functions for Type Conversion. We can convert string type objects to numeric values, perform conversion between different container types etc. In this section we will see how the conversions can be done using Python. Converting String to Numeric Types To convert from String type objects to Numeric Objects, there are different methods like int(), float() etc. Using the int() method we can convert any number as string to integer value (base 10). It takes the string type argument, default base is 10, We can also specify the ... Read More

539 Views
In this section we will see how two sorted lists can be merged using the heapq module in Python. As an example, if list1 = [10, 20, 30, 40] and list2 = [100, 200, 300, 400, 500], then after merging it will return list3 = [10, 20, 30, 40, 100, 200, 300, 400, 500]To perform this task, we will use the heapq module. This module comes with Python as Standard Library Module. So we need to import it before using it.import heapqThe heapq module has some properties. These are like below −Method heapq.heapify(iterable)It is used to convert an iterable dataset ... Read More

2K+ Views
Our task is to create a child process and display process id of both parent and child process using fork() function in Python.When we use fork(), it creates a copy of itself, it is a very important aspect of LINUX, UNIX. fork() is mainly applicable for multithreading environment that means the execution of the thread is duplicated created a child thread from a parent thread. When there is an error, the method will return a negative value and for the child process, it returns 0, Otherwise, it returns positive value that means we are in the parent process.The fork() module ... Read More