Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2542 of 3366
192 Views
A JDialog is a subclass of Dialog class and it does not hold minimize and maximize buttons at the top right corner of the window. We can create two types of JDialog boxes.in JavaModal DialogNon-Modal DialogModal JDialogIn Java, When a modal dialog window is active, all the user inputs are directed to it and the other parts of the application are inaccessible until this model dialog is closed.Non-Modal JDialogIn Java, When a non-modal dialog window is active, the other parts of the application are still accessible as normal and inputs can be directed to them, while this non-modal dialog window doesn't need to be ... Read More
573 Views
When we define a function in a python program, the purpose is to execute the code again and again by supplying different values to the function's arguments. One challenge in this design is, what if we are not sure about the number of arguments we want to process each time we call that function. This is where the special arguments called **args and **kwargs are needed. Let's look at them one by one.*argsThe *args enables us to use variable number of arguments as input to the function. In the below example we are finding out the result of multiplication of ... Read More
1K+ Views
Pandas Data Frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns. It can be created using python dict, list, and series etc. In this article, we will see how to add a new column to an existing data frame.So first let's create a data frame using pandas series. In the below example we are converting a pandas series to a Data Frame of one column, giving it a column name Month_no.Exampleimport pandas as pd s = pd.Series([6, 8, 3, 1, 12]) df = pd.DataFrame(s, columns=['Month_No']) print (df)OutputRunning the above code gives ... Read More
1K+ Views
In this article, we will learn about the implementation of a JToggleButton in Java. The JToggleButton is a basic Swing component in Java that is used to represent a two-state button, i.e., selected or unselected. It is therefore the best component to use when adding on/off or mode selection functionality to Java applications. JToggleButton A JToggleButton is an extension of AbstractButton, and it can be used to represent buttons that can be toggled ON and OFF. When JToggleButton is pressed for the first time, it remains pressed and it can be released only when it is pressed for the second ... Read More
68K+ Views
Python dictionaries are an unordered collection of key value pairs. In this tutorial we will see how we can add new key value pairs to an already defined dictionary. Below are the two approaches which we can use.Assigning a new key as subscriptWe add a new element to the dictionary by using a new key as a subscript and assigning it a value.ExampleCountryCodeDict = {"India": 91, "UK" : 44 , "USA" : 1} print(CountryCodeDict) CountryCodeDict["Spain"]= 34 print "After adding" print(CountryCodeDict)OutputRunning the above code gives us the following result −{'India': 91, 'USA': 1, 'UK': 44} After adding {'Spain': 34, 'India': 91, ... Read More
14K+ Views
As an object oriented programming language python stresses on objects. Classes are the blueprint from which the objects are created. Each class in python can have many attributes including a function as an attribute.Accessing the attributes of a classTo check the attributes of a class and also to manipulate those attributes, we use many python in-built methods as shown below.getattr() − A python method used to access the attribute of a class.hasattr() − A python method used to verify the presence of an attribute in a class.setattr() − A python method used to set an additional attribute in a class.The below ... Read More
11K+ Views
Pandas series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python objects, etc.). The elements of a pandas series can be accessed using various methods.Let's first create a pandas series and then access it's elements.Creating Pandas SeriesA panadas series is created by supplying data in various forms like ndarray, list, constants and the index values which must be unique and hashable. An example is given below.Exampleimport pandas as pd s = pd.Series([11, 8, 6, 14, 25], index = ['a', 'b', 'c', 'd', 'e']) print sOutputRunning the above code gives us the following result ... Read More
677 Views
Many times when we create python code we find that we need to access code from another python file or package. This is when you need to import that other python file or package into your current code. So the straight forward way to achieve this is just written the below statement at the top of your current python program.import package_name or module_name or from pacakge_name import module_name/object_nameWhen the above statement is parsed the interpreter does the following.The interpreter will look for names in the cache of all modules that have already been imported previously. The name of this cache ... Read More
709 Views
Ordering of data elements in a specific order is a frequently needed operation. To sort elements in an array, python uses the functions named sorted() and array.sort().sorted(array)This function returns a sorted array without modifying the original array.a = [9, 5, 3, 1, 12, 6] b = sorted([9, 5, 3, 1, 12, 6]) print "Sorted Array :", print (b) print "Original Array :", print (a)Running the above code gives us the following result −Sorted Array : [1, 3, 5, 6, 9, 12] Original Array : [9, 5, 3, 1, 12, 6]list.sort()The sort function returns a sorted array by doing in-place modification ... Read More
3K+ Views
Python does not require a main function to start execution like many other programming languages. Instead, it uses a special built-in variable called __name__ to determine how a Python script is being executed (directly or, is it imported as a module into another script). In this article, we will learn about the __name__ variable in Python. Understanding the __name__ Variable The __name__ variable is a built-in variable that holds the name of the current module. When you run a script directly, Python sets __name__ to __main__. If the same script is imported into another file as a module, __name__ ... Read More