Python Checkbox Widget in Kivy

Pradeep Elance
Updated on 12-Jan-2021 13:21:28

584 Views

Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. It is used to develop the Android application, as well as Desktops applications. In this article we will see how to use the GridLayout and CheckBox.After importing the relevant modules, we create a grid layout with 2 columns. One to hold the label and another to hold the checkboxes.Exampleimport kivy from kivy.app import App from kivy.uix.widget import Widget from kivy.uix.label import Label from kivy.uix.checkbox import CheckBox from kivy.uix.gridlayout import GridLayout # Container class for the app's ... Read More

Check If Suffix Matches with Any String in Given List in Python

Pradeep Elance
Updated on 12-Jan-2021 13:17:24

397 Views

Many times we need to analyze if a given word is present in a given list. That helps us in further processing the business logic for the data. In this article we see how to find if a given suffix which is a string is present in a list with many strings.Using anyThe any() function in python returns True if an item is present in an iterable. If nto it will return False. So in the below program we design if clauses to check for the presence or absence of the given string in the list.Example Live Demo# Given List lstA ... Read More

Memory-Mapped File Support in Python mmap

Pradeep Elance
Updated on 12-Jan-2021 13:14:23

1K+ Views

When you read a file object to a python program and want to modify, it can be done in two ways. First way is to modify the content in the physical storage drive where the file is located and the second way is to modify it directly in the memory or Ram of the system. In this article we will see how to read ,search and modify the content of a file object using the mmap module available in python. Instead of making system calls such as open, read and lseek to manipulate a file, memory-mapping puts the data of ... Read More

HTML Support in Python

Pradeep Elance
Updated on 12-Jan-2021 13:08:28

274 Views

Python has the capability to process the HTML files through the HTMLParser class in the html.parser module. It can detect the nature of the HTML tags their position and many other properties of the tags. It has functions which can also identify and fetch the data present in an HTML file.In the below example we see how to use the HTMLParser class to create a custom parser class which can only process the tags and data that we define in the class. Here we are processing the start tag, end tag and data.Below is the html which is getting processed ... Read More

Get Real-Time Currency Exchange Rate in Python

Pradeep Elance
Updated on 12-Jan-2021 13:04:42

12K+ Views

Python is very good at handling API calls. In this article we will see how we can handle the API calls for currency exchange rates in real time as well as historical.Using forex-pythonThis module provides the most direct way of getting the currency conversion rates. It has functions and parameters which can take inputs for the required currency codes and then give the result for the conversion. The below example gives the live conversion rate.Examplefrom forex_python.converter import CurrencyRates c = CurrencyRates() print(c.get_rate('USD', 'GBP'))OutputRunning the above code gives us the following result −0.7357387755Historical currency ratesWe add a datetime object ... Read More

Count Number of Binary Search Trees in a Binary Tree in C++

Sunidhi Bansal
Updated on 07-Jan-2021 07:03:44

1K+ Views

We are given a binary tree as input. The goal is to find the number of binary search trees (BSTs) present as subtrees inside it. A BST is a binary tree with left child less than root and right child more than the root.For ExampleInputThe tree which will be created after inputting the values is given below −OutputCount the Number of Binary Search Trees present in a Binary Tree are: 2Explanationwe are given with an array of integer values that is used to form a binary tree and we will check whether there is a binary search tree present in ... Read More

Construct Special Binary Tree from Given Inorder Traversal in C++

Sunidhi Bansal
Updated on 07-Jan-2021 06:59:43

470 Views

We are given an array arr[] containing the inorder traversal of a binary tree. The goal is to construct a special binary tree from that array. A special binary tree is the one which has root node’s weight greater than the weights of both its left and right children.For ExampleInputint arr[] = {10, 20, 28, 40, 32, 31, 30}OutputThe special binary tree which will be constructed with the given inorder traversal is given below −Explanationwe are given with an array of integer values or the inorder traversal of a tree. So, the special tree formed is 10, 20, 28, 40, ... Read More

Count Pairs in a Binary Tree with Given Sum X in C++

Sunidhi Bansal
Updated on 07-Jan-2021 06:55:14

225 Views

We are given an integer value and a variable x and the task is to construct the binary tree and find the pairs having sum equals to the given value x.For ExampleInputint x = 5, The tree which will be created after inputting the values is given below −OutputCount of pairs in a binary tree whose sum is equal to a given value x are: 2Explanationwe are given with an array of integer values that is used to form a binary tree and we will check whether there is a pair present in a binary tree whose sum equals to ... Read More

Construct Full K-ary Tree from Preorder Traversal in C++

Sunidhi Bansal
Updated on 07-Jan-2021 06:44:20

454 Views

We are given an array arr[] containing the preorder traversal of the k-ary tree in sequence. The goal is to construct the same k-ary tree from it and print its postorder traversal. A full k−ary tree is the one in which the root node has 0 or k children i.e. at most k child.For ExampleInputint arr[] = {2, 5, 1, 3, 6, 7, 2, 1 }, int size = 8, int children = 2OutputThe full k−ary tree which will be constructed with the two children from preorder traversal is given below −Explanationwe are given with an array of integer values ... Read More

Count Nodes Whose Sum with X is a Fibonacci Number in C++

Sunidhi Bansal
Updated on 07-Jan-2021 06:37:55

154 Views

Given a binary tree with weights of its nodes as numbers. The goal is to find the number of nodes that have weights such that the number is a Fibonacci number. Numbers in Fibonacci series are: 0, 1, 1, 2, 3, 5, 8, 13….nth number is the sum of (n−1)th and (n−2)th. If weight is 13 then it is a Fibonacci number so the node will be counted.For ExampleInputtemp =1. The tree which will be created after inputting the values is given below −OutputCount the nodes whose sum with X is a Fibonacci number are: 3Explanationwe are given with the ... Read More

Advertisements