GUI window has many controls such as labels, buttons, text boxes, etc. We may sometimes want the content of our controls such as labels to update automatically while we are viewing the window.We can use after() to run a function after a certain time. For example, 1000 milliseconds mean 1 second. The function which we call continuously after a certain amount of time will update the text or any updation you want to happen.We have a label on our window. We want the text of the label to update automatically after 1 second. To keep the example easy, suppose we ... Read More
When it is required to filter the tuples by the 'K'th element from a list, list comprehension and 'in' operators can be used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).A list of tuple basically contains tuples enclosed in a list. The 'in' operators checks to see if the specific data is present in the iterable/data or not.The list comprehension is a shorthand to iterate through the list and perform operations on it.Below is a demonstration of the same −ExampleLive Demomy_list = [(1, 21), (25, 'abc', ... Read More
When it is required to perform tuple division in Python, the 'zip' method and generator expressions can be used.The zip method takes iterables, aggregates them into a tuple, and returns it as the result.Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as well as raises 'StopIteration' exception when no values are present that could be returned.Below is a demonstration of the same −ExampleLive Demomy_tuple_1 = ( 7, 8, 3, 4, 3, 2) my_tuple_2 = (9, 6, 8, 2, 1, 4) print ("The ... Read More
The list is a linear data structure containing data elements.Example1, 2, 3, 4, 5, 6Dictionary is a data structure consisting of key: value pairs. Keys are unique and each key has some value associated with it.Example1:2, 3:4, 5:6Given a list, convert this list into the dictionary, such that the odd position elements are the keys and the even position elements are the values as depicted in the above example.Method 1 − Iterating over the listExample Live Demodef convert(l): dic={} for i in range(0, len(l), 2): dic[l[i]]=l[i+1] return dic ar=[1, 'Delhi', 2, 'Kolkata', 3, ... Read More
When it is required to perform 'XOR' operations on the elements of one tuple, the 'zip' method and the generator expression can be used.The zip method takes iterables, aggregates them into a tuple, and returns it as the result.Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as well as raises 'StopIteration' exception when no values are present that could be returned.Below is a demonstration of the same −ExampleLive Demomy_tuple_1 = ( 7, 8, 3, 4, 3, 2) my_tuple_2 = (9, 6, 8, 2, ... Read More
When it is required to raise the elements of one tuple, as a power of another tuple, the 'zip' method and the generator expression can be used.The zip method takes iterables, aggregates them into a tuple, and returns it as the result.Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as well as raises 'StopIteration' exception when no values are present that could be returned.Below is a demonstration of the same −ExampleLive Demomy_tuple_1 = ( 7, 8, 3, 4, 3, 2) my_tuple_2 = (9, ... Read More
When it is required to concatenate two string tuples, the 'zip' method and the generator expression can be used.The zip method takes iterables, aggregates them into a tuple, and returns it as the result.Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as well as raises 'StopIteration' exception when no values are present that could be returned.Below is a demonstration of the same −ExampleLive Demomy_tuple_1 = ('Jane', 'Pink', 'El') my_tuple_2 = ('Will', 'Mark', 'Paul') print ("The first tuple is : " ) print(my_tuple_1) ... Read More
Converting Text to Speech basically refers to a program where you give input as a text and the output you receive is the input text in the form of a speech.Python offers the text to speech conversion with the help of APIs. One such API which serves this purpose is the Google Text to Speech API , known as gTTS. The gTTS enables to conversion the provided text into speech and save the output as audio.Step 1 − Install gTTSTo use the gTTS Text to speech conversion tool, we need to install it first. Installing the gTTS is pretty easy.Open ... Read More
A python is an object-oriented programming language. Almost everything in Python is considered as an object. An object has its own properties(attributes) and behavior(methods).A class is a blueprint of the objects or can be termed as object constructor for creating objects.One class can have many objects and value of properties for different objects can be different.Example of properties and behavior of an objectLet’s take the example of car as an object. Its properties will include its color, company name, year of manufacture , price , mileage etc. The behavior of the car will include the functions it can perform, this ... Read More
Merge sort is a sorting technique. It is an efficient sorting algorithm with a time complexity of (n logn) where n is the length of the array to be sorted.Merge sort is an algorithm that follows the Divide and Conquers paradigm. It continuously divides the array into two equal halves. Later it starts sorting the lists having a single element each and continuously merges the sorted lists to form the complete sorted list.Hence, we obtain a sorted array.ExampleThe purple boxes and black arrows show the splitting of the list into two halves.The green boxes and red arrows show the merging ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP