Found 10784 Articles for Python

Design a Keylogger in Python

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

4K+ Views

Here we are going to develop a keylogger using python. But before that, what is a keylogger? Keylogger is a program with which we monitor keystrokes. These keystrokes will be stored in a log file. We can record sensitive information like username and password using this keystroke.To create a keylogger we are going to use the pynput module. As its not the standard library of python, we might need to install it.Installing pyxhook module −I’m going to use pip to install pynput −pip install pynput Requirement already satisfied: pynput in c:\python\python361\lib\site-packages (1.4) Requirement already satisfied: six in c:\python\python361\lib\site-packages (from pynput) ... Read More

Develop Notepad using Tkinter in python

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

2K+ Views

Tkinter is a GUI library from python from which we can create multiple GUI apps. Here, using tkinter we will develop a notepad like text editor. This notepad will have the menu where we can create new file, open existing file, save the file, editing, cut and paste, all functionality will there.PrerequisitePython installed.Tkinter installed.Note: tkinter comes as a standard library with python 3.x.Adding menu items:Our notepad will have four main menu items: File, Edit, Commands & Help. Our file menu item will have four sub-items- New, Open, Save & Exit.Our edit menu item will have three sub-items- cut, copy & ... Read More

Generating random Id’s in Python

Samual Sam
Updated on 30-Jun-2020 09:19:37

2K+ Views

We use to generate a random number in our project for a sample data, which later can be used for testing, filled empty columns or for many other purposes, the key thing is we need to generate random data. In python, there are numerous ways to generate random data and we're going to explore some of them here in this article −Python random() moduleOne of the important library, what comes with python is random and we are going to use it throughout in our code.To use this module in your code, you just need to import it, that’s it and ... Read More

SHA encoding using Python?

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

784 Views

One of the major concern of all IT companies in the security of there data. Multiple hashing techniques are there to project and check our data.What is HashHash is a function which takes variable length sequence of bytes as input and converts it to a fixed length sequence. However, to get your original data(input bytes) back is not easy. For example, x is your input and f is the f is the hashing function, then calculating f(x) is quick and easy but trying to obtain x again is a very time-consuming job.The return value from a hash function is called ... Read More

MD5 hash encoding using Python?

Samual Sam
Updated on 30-Jun-2020 09:23:44

4K+ Views

One of the major concern of all IT companies in the security of there data. Multiple hashing techniques are there to project and check our data.What is HashHash is a function which takes variable length sequence of bytes as input and converts it to a fixed length sequence. However, to get your original data(input bytes) back is not easy. For example, x is your input and f is the f is the hashing function, then calculating f(x) is quick and easy but trying to obtain x again is a very time-consuming job.The return value from a hash function is called ... Read More

Python Pickling

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

14K+ Views

Python pickle module is used for serializing and de-serializing python object structures. The process to converts any kind of python objects (list, dict, etc.) into byte streams (0s and 1s) is called pickling or serialization or flattening or marshalling. We can converts the byte stream (generated through pickling) back into python objects by a process called as unpickling.Why Pickle?: In real world sceanario, the use pickling and unpickling are widespread as they allow us to easily transfer data from one server/system to another and then store it in a file or database.Precaution: It is advisable not to unpickle data received ... Read More

Print Colors of terminal in Python

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

610 Views

In the terminal, if you want to make some texts appears in colored mode, there are numerous ways in python programming to achieve it.Using python modules1.termcolor module: It is the ANSII Color formatting for output in the terminal.import sys from termcolor import colored, cprint text1 = colored('Hello, Tutorialspoint!', 'blue', attrs=['reverse', 'blink']) print(text1) cprint('Hello, Python!', 'blue', 'on_white') print_red_on_blue = lambda x: cprint(x, 'red', 'on_blue') print_red_on_blue('Hello, from Data Science!') print_red_on_blue('Hello, Python!') for i in range(10):    cprint(i, 'green', end=' ') cprint("Attention!", 'blue', attrs=['bold'], file=sys.stderr)ResultRead More

Basic Slicing and Advanced Indexing in NumPy Python

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

415 Views

Indexing of ndarrays can be done using the standard python x[obj] syntax, where x is the array and obj the selection.There are three kinds of indexing available −field accessbasic slicingadvanced indexingWhat kind of indexing will be there depends on obj. In this section, we are going to mainly concentrate on basic slicing & advanced indexing.We can divide advanced indexing into two parts −Integer array indexingBoolean indexingBasic SlicingPython basic concept of slicing is extended in basic slicing to n dimensions. As with python slice object which is constructed by giving a start, stop & step parameters to slice function. To get ... Read More

Differences between Flatten() and Ravel() in Numpy

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

218 Views

There are numerous ways to create a numpy array. Numpy provides two different kinds of ways to convert a ndarray to 1Darray: that is using the flatten() method and the other using the ravel() method.Example#Import required library, numpy import numpy as np #create an array from a list arr = np.array( [ (2, 7, 3, 4), (5, 6, 9, 1)]) #flatten_output print(arr.flatten()) #ravel_output print(arr.ravel())Output[2 7 3 4 5 6 9 1] [2 7 3 4 5 6 9 1]Now above we can see that both functions return the same list, so the question arises, why two methods for the same ... Read More

Replacing strings with numbers in Python for Data Analysis

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

723 Views

Sometimes there is a requirement to convert a string to a number (int/float) in data analysis. For each string, we can assign a unique integer value to differentiate string values.For this, we use the data in Comma Separated Values(CSV) files. Say we have an excel file containing CSV data as follow −CompanyIndustryRecommendationHDFC BankFinanceHoldApolloHealthcareBuyHeroAutomobileUnderperformYes BankFinanceHoldM&MAutomobileUnderperformFortisHealthcareBuyMarutiAutomobileUnderperformAbove is just a few lines from a large dataset, we need to give different recommendation .i.e. Buy, Hold, Underperform etc. integer values, which will link to our metadata. So for the above input, our expected output will be something like −CompanyIndustryRecommendationHDFC BankFinance2ApolloHealthcare1HeroAutomobile3Yes BankFinance2M&MAutomobile3FortisHealthcare1MarutiAutomobile3Here is a way ... Read More

Advertisements