Programming Articles - Page 2466 of 3366

chr () in Python

Pradeep Elance
Updated on 23-Aug-2019 11:42:08

1K+ Views

This function return the string representing a character whose Unicode code point is the integer supplied as parameter to this function. For example, chr(65) returns the string 'A', while chr(126) returns the string '~'.SyntaxThe syntax of the function is as below.chr(n) where n is an integer valueExampleThe below program shows how the chr() is used. We supply various integer values as parameter and get back the respective characters. Live Demo# Printing the strings from chr() function print(chr(84), chr(85), chr(84), chr(79), chr(82))Running the above code gives us the following result −T U T O RUsing a series of numbersWe can take help ... Read More

Change Data Type for one or more columns in Pandas Dataframe

Pradeep Elance
Updated on 23-Aug-2019 11:30:14

2K+ Views

Many times we may need to convert the data types of one or more columns in a pandas data frame to accommodate certain needs of calculations. There are some in-built functions or methods available in pandas which can achieve this.Using astype()The astype() method we can impose a new data type to an existing column or all columns of a pandas data frame. In the below example we convert all the existing columns to string data type.Example Live Demoimport pandas as pd #Sample dataframe df = pd.DataFrame({    'DayNo': [1, 2, 3, 4, 5, 6, 7],    'Name': ['Sun', 'Mon', 'Tue', 'Wed', ... Read More

What will happen if we directly call the run() method in Java?

Vivek Verma
Updated on 18-Jun-2025 19:00:48

295 Views

The run() method of the Thread class is called internally after the start() method is invoked to begin a new thread. However, if the run() method is called directly (without start()), it does not start a separate thread and executes within the current thread. The run() Method In Java, the run() method of the Thread class is used to define the sequence of actions that a thread will execute. This method will be invoked by the Java Virtual Machine (JVM) implicitly; we can also invoke this method explicitly in the current thread without calling the start() method. Note! The run() ... Read More

Calculate n + nn + nnn + ? + n(m times) in Python

Pradeep Elance
Updated on 23-Aug-2019 10:47:57

470 Views

There are a variety of mathematical series which python can handle gracefully. One such series is a series of repeated digits. Here we take a digit and add it to the next number which has two such digits and again the next number is three such digits and so on. Finally, we calculate the sum of all such numbers in the series.ApproachWe take a digit and convert it to string. Then concatenate two such strings to get the double digit number and keep concatenating to get higher numbers of such digits. Then we implement a recursive function to add all ... Read More

How can we implement transparent JDialog in Java?

raja
Updated on 12-Feb-2020 06:36:45

474 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. There are two types of dialog boxes namely, modal and non-modal. The default layout for a dialog box is BorderLayout.In the below program, we can implement a transparent JDialog by customizing the AlphaContainer class and override the paintComponent() method.Exampleimport java.awt.*; import javax.swing.*; public class TransparentDialog {    public static void main (String[] args) {       JDialog dialog = new JDialog();       dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);       dialog.getRootPane().setOpaque(false);       dialog.setUndecorated(true);       dialog.setBackground(new Color (0, 0, ... Read More

How to print the maximum occurred character of a string in Java?

Vivek Verma
Updated on 08-May-2025 16:34:12

736 Views

A String class can be used to represent character strings; all the string literals in Java programs are implemented as instances of the String Class. In Java, Strings are constants and their values cannot be changed (immutable) once declared.Printing Maximum Occurred Character The maximum occurring character of a string refers to the character that appears multiple times (more than any other character in a string) in a string. To count the maximum occurring character of a string, we have the following approaches - Using an Array Using HashMap Using an Array Using an array is one way to ... Read More

How to check the memory used by a program in Java?

Vivek Verma
Updated on 14-May-2025 11:18:07

3K+ Views

This article will discuss "how to check the memory used by a program" in Java, including a brief introduction of the process for calculation and an appropriate example that correctly checks the memory usage by the program. Understanding Memory Usage in Java Programs A Java code that takes a long time to execute, makes heavy use of dynamic memory. In such scenarios,  we may end up with Out-of-Memory errors (due to a memory shortage of the heap space). We can calculate the memory space (heap) used by a Java program using the methods provided by the Runtime class.If the heap space is ... Read More

Importance of SerialVersionUID keyword in Java?

raja
Updated on 02-Jul-2020 09:02:37

6K+ Views

SerialVersionUIDThe SerialVersionUID must be declared as a private static final long variable in Java. This number is calculated by the compiler based on the state of the class and the class attributes. This is the number that will help the JVM to identify the state of an object when it reads the state of the object from a file.The SerialVersionUID can be used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible w.r.t serialization. If the deserialization object is different than serialization, then it can throw an InvalidClassException.If the serialVersionUID is ... Read More

Print shortest path to print a string on screen in C Program.

Sunidhi Bansal
Updated on 22-Aug-2019 09:14:49

321 Views

Given a string, the program must display the shortest path which will print the string over the screen using that shortest path.Like screen will store alphabets in the formatA B C D E F G H I J K L M N O P Q R S T U V W X Y ZExampleInput: HUP Output : Move Down Move Down Move Down destination reached Move Left Move Left Move Down Move Down Move Down destination reached Move Up destination reachedThe approach used here is to store the characters in the n x n matrix and perform the following operation ... Read More

Print sorted distinct elements of array in C language

Sunidhi Bansal
Updated on 22-Aug-2019 09:08:29

582 Views

Given with an array of integer elements, the task is to remove the duplicate values and print the distinct elements in sorted manner.Given below is an array that stores integer type values in the fashion 4, 6, 5, 3, 4, 5, 2, 8, 7 and 0 now, the result will print the sorted elements as 0, 2, 3, 4, 4, 5, 5, 6, 7 and 8 but this result still contains duplicate values 4 and 5 which should be removed and the final result will be 0, 2, 3, 4, 5, 6, 7 and 8ExampleInput: array[] = {4, 6, 5, ... Read More

Advertisements