Found 33676 Articles for Programming

Scraping and Finding Ordered Word in a Dictionary in Python

karthikeya Boyini
Updated on 26-Jun-2020 12:37:10

675 Views

For solving this problem we need requests module.For installing requests module, we need this command to get executed at command line.pip install requestsScrapingImport requests module.Then we need to fetch data from URL.Using UTF-8 decode the text.Then convert string into a list of words.Ordered FindingTraverse the list of words using loop.Then compare the ASCII value of adjacent character of each word.If the comparison is true then print ordered word otherwise store the unordered word.Example codeimport requests    def Words_find():       my_url = ""#put thisurl of .txt files in any website       my_fetchData = requests.get(my_url)       ... Read More

Underscore(_) in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

665 Views

In Python in some cases we use Single Underscore(_) and some cases we use Double Underscores (__). In Python has following cases, where we use underscore. If we want to store the value of last expression in interpreter. If we want to ignore some values. For declaration of variable or function. To separate digits of number lateral value. It is also used as ‘Internationalization (i18n)’ or ‘Localization (l10n)’ functions. Now some examples on every cases. Used in interpreter The Python Interpreter stores the last expression value in the '_'. >>> 20 20 >>> _ ... Read More

JSON Formatting in Python

Samual Sam
Updated on 26-Jun-2020 12:26:45

9K+ Views

The JSON (Java Script Object Notation) is light weight, well accepted data interchange format. Using JSON formatting techniques in Python, we can convert JSON strings to Python objects, and also convert Python Objects to JSON strings.To use these functionalities, we need to use the json module of Python. The json module comes with the Python standard library. So at first we have to import it first.import jsonConverting Python objects to JSON StringIn the json module, there are some methods like dump(), and dumps() to convert Python objects to JSON strings. The dump() method takes two arguments, the first one is ... Read More

Type Conversion in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

1K+ Views

Using Python, we can easily convert data into different types. There are different functions for Type Conversion. We can convert string type objects to numeric values, perform conversion between different container types etc. In this section we will see how the conversions can be done using Python. Converting String to Numeric Types To convert from String type objects to Numeric Objects, there are different methods like int(), float() etc. Using the int() method we can convert any number as string to integer value (base 10). It takes the string type argument, default base is 10, We can also specify the ... Read More

Merge two sorted arrays in Python using heapq?

Samual Sam
Updated on 26-Jun-2020 12:19:06

542 Views

In this section we will see how two sorted lists can be merged using the heapq module in Python. As an example, if list1 = [10, 20, 30, 40] and list2 = [100, 200, 300, 400, 500], then after merging it will return list3 = [10, 20, 30, 40, 100, 200, 300, 400, 500]To perform this task, we will use the heapq module. This module comes with Python as Standard Library Module. So we need to import it before using it.import heapqThe heapq module has some properties. These are like below −Method heapq.heapify(iterable)It is used to convert an iterable dataset ... Read More

Creating child process using fork() in Python

karthikeya Boyini
Updated on 26-Jun-2020 12:19:41

2K+ Views

Our task is to create a child process and display process id of both parent and child process using fork() function in Python.When we use fork(), it creates a copy of itself, it is a very important aspect of LINUX, UNIX. fork() is mainly applicable for multithreading environment that means the execution of the thread is duplicated created a child thread from a parent thread. When there is an error, the method will return a negative value and for the child process, it returns 0, Otherwise, it returns positive value that means we are in the parent process.The fork() module ... Read More

Determine if a String is a legal Java Identifier

karthikeya Boyini
Updated on 26-Jun-2020 12:20:41

890 Views

To determine if a String is a legal Java Identifier, use the Character.isJavaIdentifierPart() and Character.isJavaIdentifierStart() methods.Character.isJavaIdentifierPart()The java.lang.Character.isJavaIdentifierPart() determines if the character (Unicode code point) may be part of a Java identifier as other than the first character.A character may be part of a Java identifier if any of the following are true.it is a letterit is a currency symbol (such as '$')it is a connecting punctuation character (such as '_')it is a digitit is a numeric letter (such as a Roman numeral character)Character.isJavaIdentifierStart()The java.lang.Character.isJavaIdentifierStart() determines if the character (Unicode code point) is permissible as the first character in a Java ... Read More

Java Program to compare two Java char Arrays

Samual Sam
Updated on 26-Jun-2020 12:21:12

387 Views

To compare two Java char arrays, use the Arrays.equals() method.Let us first declare and initialize some char arrays.char[] arr1 = new char[] { 'p', 'q', 'r' }; char[] arr2 = new char[] { 'p', 'r', 's' }; char[] arr3 = new char[] { 'p', 'q', 'r' };Now let us compare any two of the above arrays.Arrays.equals(arr1, arr2));In the same way, work it for other arrays and compare them.The following is an example.Example Live Demoimport java.util.*; public class Demo {    public static void main(String []args) {       char[] arr1 = new char[] { 'p', 'q', 'r' };     ... Read More

Convert string to char array in Java

karthikeya Boyini
Updated on 26-Jun-2020 12:21:40

4K+ Views

The following is our string.String str = "Tutorial";Now, use the toCharArray() method to convert string to char array.char[] ch = str.toCharArray();Now let us see the complete example.Example Live Demopublic class Demo {    public static void main(String []args) {       String str = "Tutorial";       System.out.println("String: "+str);       char[] ch = str.toCharArray();       System.out.println("Character Array...");       for (int i = 0; i < ch.length; i++) {          System.out.print(ch[i]+" ");       }    } }OutputString: Tutorial Character Array... T u t o r i a l

Java Program to determine a Character\'s Unicode Block

Alshifa Hasnain
Updated on 14-Feb-2025 18:59:17

565 Views

In this article, we will learn to represent the Unicode block containing the given character in Java. Unicode provides a standardized way to represent characters from various writing systems across the world. In Java, characters belong to different Unicode Blocks, which help in categorizing them based on language, symbols, and special characters. Understanding Unicode Blocks A Unicode Block is a range of Unicode characters grouped together based on similar properties.For example: Basic Latin (U+0000 to U+007F) contains English letters and symbols. CJK Unified Ideographs (U+4E00 to U+9FFF) contains Chinese, Japanese, and ... Read More

Advertisements