Skip to main content

Posts

Showing posts from March, 2020

MUTABLE AND IMMUTABLE OBJECTS IN PYTHON AND THEIR MEMORY MANAGEMENT

Everything in Python is an object. There are two types of objects in Python Mutable Immutable Mutable objects are those whose value can be changed after their creation. An example of it is a  list. Immutable objects are those whose value cannot be changed after their creation. A well-known example of this is a tuple. Mutable objects: lists, sets, dictionaries Immutable objects: Tuples, integers, floats, strings, frozen sets Before going deep into this topic, we should know about the  id() function in Python. id() function in python: This function returns the identity of an object. This is guaranteed to be unique and constant for an object. The id of an object is created when the object is created. See below for examples. example1 :                                                          ...

MAP, LAMBDA AND SETS IN PYTHON

Hello guys, welcome to my blog. Here I am going to tell you about the map, lambda, and sets in python. MAP FUNCTION IN PYTHON: When working with iterables in the python-like lists, we use for loops to apply the operations on elements of the iterables, but we know that for loops in the python are quite slow. Don't worry, for this, we have MAP function in the python. Its syntax is map(fun,iterable) It creates a map object. The 1st argument in the map function is the operation we do on the elements of the iterable. The 2nd argument in it is iterable on which you perform the operation. The map function returns the list containing the elements on which the operation is done. Look at the below example: l1=[1,2,3] def func(x):     return 2*x l=list(map(func,l1)) print(l1) Output: [2,4,6] In the above example, the function func accepts the element and returns the double of the element. To perform this operation on an iterable we loop through it. But here we us...

CHATBOT WITH SPEECH RECOGNITION AND PYTTSX3 USING PYTHON

NOTE: VIEW THIS POST IN DESKTOP SITE FOR THE BEST EXPERIENCE Hello guys. Welcome to my blog. Here I will explain to you how to create a chatbot that has speech as it’s both input and also output. So, let us get started. In this tutorial, I am using some of the libraries in Python like SpeechRecognition, Pyaudio, Chatterbot et cetera. I am going to explain to you how to install these libraries and work with them one by one separately and at last how to integrate them. SPEECH TO TEXT At first, you have to install the Speech Recognition library. You should not use the Python3.7 version because it does not support speech recognition. I am using a 3.6 version for this tutorial. Now, you should install the speech recognition library from the command prompt. Use the following command. pip3.6 install SpeechRecognition Now, you should install PyAudio. First, you have to find the version of your Python and also the configuration of your machine. Open your cmd and type p...