Python's interactive mode works on the principle of REPL (Read - Evaluate - Print - Loop). The code module in Python's standard library provides classes nd convenience functions to set up REPL environment from within Python script.Following two classes are defined in code module:InteractiveInterpreter: This class deals with parsing and interpreter state (the user’s namespace)InteractiveConsole: Closely emulate the behavior of the interactive Python interpreter.Two convenience functions in the module are:interact(): Convenience function to run a read-eval-print loop.compile_command(): This function is useful for programs that want to emulate Python’s interpreter main loop (the REPL).Interactive Interpreter methodsrunsource(): Compile and run some source ... Read More
In wireless LANs (wireless local area networks), the exposed terminal problem is a transmission problem that arises when a transmitting station is prevented from sending frames due to interference with another transmitting station. This is prevalent in decentralised systems where there aren’t any entity for controlling transmissions. This occurs when a station is visible from a wireless access point (AP), but not from other stations that communicate with the AP.Problem IllustrationSuppose that there are four stations labelled STA, STB, STC, and STD, where STB and STC are transmitters while STA and STD are receivers at some slot of time. The ... Read More
To get the number of levels above a node, use the getLevel() method. Following is an example for the root node “node” −node.getLevel()Note − The value 0 is returned if the node is a root node since there are zero levels above the root node.For other nodes, get the number of levels above a node as shown below with node3 −node3.getLevel()The following is an example to get the number of levels above a node in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo { public static void main(String[] args) throws Exception { ... Read More
Let us first create a collection with documents −> dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "John" }, "StudentAge":21 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227acb64a577be5a2bc07") } > dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "JOHN" }, "StudentAge":19 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227b8b64a577be5a2bc08") } > dbworkingOfRegularExpressionDemoinsertOne({ "StudentDetails" : { "StudentName" : "Carol" }, "StudentAge":20 }); { "acknowledged" : true, "insertedId" : ObjectId("5cf227c2b64a577be5a2bc09") }Following is the query to display all documents from a collection with the help of find() method −> dbworkingOfRegularExpressionDemofind();This will produce the following document −{ "_id" : ObjectId("5cf227acb64a577be5a2bc07"), "StudentDetails" : ... Read More
For this, you can create a stored procedure. Let us first create a table.mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.55 sec)Following is the query to create a stored procedure to auto insert values to a table from range 10 to 20 −mysql> DELIMITER // mysql> CREATE PROCEDURE AutoInsertValuesToTable() -> BEGIN -> DECLARE startingRange INT DEFAULT 10; -> WHILE startingRange INSERT DemoTable(Value) VALUES (startingRange ); -> SET startingRange = startingRange + 1; -> ... Read More
Following is the Java program to print diagonal pattern of a given matrix.Example Live Demopublic class DiagonalMatrix { public static void main(String args[]){ int a[][]={{1,2,3},{4,5,6},{7,8,9}}; int rows = a.length; int columns = a[0].length; for (int i = 0; i < rows; i++) { for (int r = i, c = 0; r >= 0 && c < columns; r--, c++){ System.out.print(a[r][c] + " "); } System.out.println(); } for (int i = 1; i < columns; i++) { for (int r = rows-1, c = i; r >= 0 && c < columns; r--, c++) { System.out.print(a[r][c] + " "); } System.out.println(); } } }Output1 4 2 7 5 3 8 6 9
The DOM setNamedItem() method set a node specified in its parameter to an attribute node using its name in an HTML document.SyntaxFollowing is the syntax −node.setNamedItem(node);ExampleLet us see an example of setNamedItem() method − Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } .btn{ background:#0197F6; border:none; height:2rem; border-radius:2px; width:50%; margin:2rem auto; ... Read More
Here we will see how to get the number A raise to the power B using bash script. The logic is very simple. We have to use the ‘**’ operator or power operator to do this. Let us see the following program to understand the concept clearly.Example#!/bin/bash # GNU bash Script a=5 b=6 echo "$(($a ** $b))"Output15625
Here we will see how to print some lines into the linux terminal with some color. Here we are doing anything special into C++ code. We are just using some linux terminal commands to do this. The command for this kind of output is like below.\033[1;31m Sample Text \033[0mThere are some codes for text styles and colors. These are listed below.ColorForeground CodeBackground CodeBlack3040Red3141Green3242Yellow3343Blue3444Magenta3545Cyan3646White3747Some additional options are like below −OptionCodeDescriptionReset0Back to normal (remove all styles)Bold1Bold the textUnderline4Underline textInverse7Interchange colors of background and foregroundBold off21Normal from boldUnderline off24Normal from UnderlineInverse off27Reverse of the InverseExample#include using namespace std; main() { cout Read More
Cookies are small files which are stored on a user's device while browsing internet.When we talk about cookies in iPhone we usually talk about application using the Web Views or the browser applications.A normal iOS application does not contains cookies. An app will have cookies only if the application has one or more web views.To check where are the app cookies stored on iPhone, On an iPhone, go to Settings -> Safari -> Advanced -> Website Data and you will see all cookies stored on your device.For iOS Application using web view The UIWebView will automatically store the cookies in the sharedHTTPCookieStorage.Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP