Karthikeya Boyini has Published 2383 Articles

What does the method toArray() do?

karthikeya Boyini

karthikeya Boyini

Updated on 12-Mar-2020 12:16:49

663 Views

The toArray() method of the java.util.The ArrayList class returns an array containing all of the elements in this list in proper sequence (from first to the last element). This acts as a bridge between array-based and collection-based APIs.ExampleLive Demoimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) ... Read More

MySQL query to select records from a table on the basis of a particular month number?

karthikeya Boyini

karthikeya Boyini

Updated on 06-Mar-2020 10:29:45

446 Views

You can select specific month with the help of MONTH() function. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE MONTH(yourColumnName) = yourValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UserLoginTimeInformation    -> (   ... Read More

What information does SHOW TABLE DOES display in MySQL

karthikeya Boyini

karthikeya Boyini

Updated on 06-Mar-2020 10:05:22

80 Views

The SHOW TABLE STATUS in MySQL displays the NAME, ENGINE, VERSION, ROWS, CHECKSUM, etc of a table −ExampleLet us first create a table. Here, we are using the MyISAM engine. The query to create a table is as follows −mysql> create table Post_Demo    -> (    -> PostId int, ... Read More

HAVING with GROUP BY in MySQL

karthikeya Boyini

karthikeya Boyini

Updated on 06-Mar-2020 10:03:50

323 Views

To use HAVING with GROUPBY in MySQL, the following is the syntax. Here, we have set a condition under HAVING to get check for maximum value condition −SELECT yourColumnName FROM yourTableName GROUP BY yourColumnName HAVING MAX(yourColumnName) < yourValue;Let us see an example by creating a table in MySQL −mysql> create ... Read More

How to add/subtract large numbers using Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 11:15:16

1K+ Views

You can add/subtract large numbers in python directly without worrying about speed. Python supports a "bignum" integer type which can work with arbitrarily large numbers. In Python 2.5+, this type is called long and is separate from the int type, but the interpreter will automatically use whichever is more appropriate.As ... Read More

How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 10:38:46

955 Views

Python provides straightforward functions to convert Decimal to Binary, Octal, and Hexadecimal. These functions are −Binary: bin() Octal: oct() Hexadecimal: hex()ExampleYou can use these functions as follows to get the corresponding representation −decimal = 27 print(bin(decimal), "in binary.") print(oct(decimal), "in octal.") print(hex(decimal), "in hexadecimal.")OutputThis will give the output −0b11011 ... Read More

How to generate JSON output using Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 10:16:33

2K+ Views

The json module in python allows you to dump a dict to json format directly. To use it, Exampleimport json my_dict = {    'foo': 42,    'bar': {       'baz': "Hello",       'poo': 124.2    } } my_json = json.dumps(my_dict) print(my_json)OutputThis will give the ... Read More

How can I loop over entries in JSON using Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 08:11:45

1K+ Views

You can parse JSON files using the json module in Python. This module parses the json and puts it in a dict. You can then get the values from this like a normal dict. For example, if you have a json with the following content −{    "id": "file",   ... Read More

How to compare two variables in an if statement using Python?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 07:52:57

5K+ Views

You can compare 2 variables in an if statement using the == operator. examplea = 10 b = 15 if a == b:    print("Equal") else:    print("Not equal")OutputThis will give the output −Not EqualYou can also use the is the operator. examplea = "Hello" b = a if a is b: ... Read More

Do you think Python Dictionary is really Mutable?

karthikeya Boyini

karthikeya Boyini

Updated on 05-Mar-2020 07:13:52

177 Views

Yes, Python Dictionary is mutable. Changing references to keys doesn't lead to the creation of new dictionaries. Rather it updates the current dictionary in place. examplea = {'foo': 1, 'bar': 12} b = a b['foo'] = 20 print(a) print(b)OutputThis will give the output −{'foo': 20, 'bar': 12} {'foo': 20, 'bar': 12}

Advertisements