Found 26504 Articles for Server Side Programming

Haskell Program to convert Binary to Decimal

Akhil Sharma
Updated on 13-Mar-2023 15:03:39

854 Views

In Haskell, we can use functions like foldl, recursion, and list comprehension to convert a binary number to decimal. In the first example, we are going to use (binToDec = foldl (\acc x -> 2*acc + digitToInt x) 0) and in the second example, we are going to use base case, (binToDec "" = 0) and recursive case, (binToDec (x:xs) = 2 * binToDec xs + digitToInt x) function. And in the third example, we are going to use (binToDec = sum . zipWith (\x y -> 2^x * digitToInt y) [0..] . reverse). Algorithm Step 1 − ... Read More

Haskell Program to convert Decimal to Binary

Akhil Sharma
Updated on 13-Mar-2023 15:02:36

1K+ Views

In Haskell, we will convert Decimal to Binary by using reverse function , tail recursion, and divMod function. In the first example, we are going to use (decToBin n | n < 0 = error "Input must be non-negative" | n == 0 = "0" | otherwise = reverse $ decToBin' n) and in the second example, we are going to use (binDigits 0 = "" and binDigits n = let (q, r) = n `divMod` 2 in show r ++ binDigits q) function. Method 1: Using reverse function and tail recursion In ... Read More

Haskell Program to convert Decimal to Hexadecimal

Akhil Sharma
Updated on 13-Mar-2023 15:01:44

628 Views

In Haskell, we can use intToDigits, showIntAtBase and format functions to convert a decimal to Hexadecimal number. In the first example, we are going to use (decToHex n = reverse (hexChars n) where hexChars 0 = "" and hexChars x = intToDigit (x `mod` 16) : hexChars (x `div` 16)) and in the second example, we are going to use (decToHex n = showIntAtBase 16 intToDigit n "") function. In the third example, we are going to use (decToHex n = printf "%X" n) function. Method 1: Using reverse and intToDigits functions In this method, the Data.Char module is ... Read More

Case-specific sorting of strings

Mallika Gupta
Updated on 15-Mar-2023 10:21:25

472 Views

Strings are the storage elements for storing different kinds of letters and symbols. It is indicative of a stream of characters in C++. Strings are denoted in double quotes or single quotes. The given input string can be comprised of both uppercase and lowercase characters. The problem statement is to change the case of the characters of the string, in such a way that the letter which was originally written in lowercase is converted into uppercase and vice versa. Some of the examples illustrating the problem statement are as follows − Sample Examples Example 1 : "AbCd" Output : bAdC ... Read More

Which is the Best GUI Software for Python?

Tushar Sharma
Updated on 13-Mar-2023 13:14:50

973 Views

Python is a very well-liked programming language, and this trend is continuing. The availability of several libraries, tools, and frameworks for developing graphical user interfaces is a major factor in their popularity (GUIs). Graphical User Interface in Python is referred to as Python GUI. It is a technique for developing graphical user interfaces for Python programs. A GUI is a form of user interface that replaces text-based or command-line interfaces with graphical components like buttons, menus, text fields, and images to let users interact with software programs. There are a few factors you need to consider while deciding on the ... Read More

What Kinds of Jobs are Available for a Freelance Python Developer?

Tushar Sharma
Updated on 13-Mar-2023 13:08:24

285 Views

Python is a popular and often used programming language in different parts of the world. It is a top choice for many projects, from scientific research to web development, because of its adaptability and simplicity of usage. It is obvious that there is a greater demand for Python developers given its acceptance and utility. Freelance Python coders are now even more in demand as a result of the increase in remote employment opportunities. Working on a variety of projects and collaborating with a variety of clients are opportunities available to you as a freelance Python developer. You can find a ... Read More

What is the Next Big Thing in Python?

Tushar Sharma
Updated on 13-Mar-2023 13:06:07

285 Views

Python, a powerful programming language, has transformed the computer industry with its unmatched simplicity, friendliness, and versatility. If you're establishing a website, analyzing data, or developing artificial intelligence, Python has you covered. Python's rise as one of the most sought-after programming languages in the computer industry is not surprising. What will, however, be Python's next major development? Keep reading to find out! Several new features and enhancements are scheduled for the most recent releases of Python as it continues to develop. Below are a few of the significant developments that Python is anticipated to support. More informative tracebacks lead ... Read More

What Does while true do in Python?

Tushar Sharma
Updated on 04-Apr-2023 16:27:28

2K+ Views

Popular loop structures like "While true" may be found in various computer languages, including Python 3.11.1. This kind of loop continues indefinitely until a specific condition is satisfied, at which point it ends. This loop is very helpful when you need to carry out the same operation repeatedly until a particular event occurs. The following Python code demonstrates the syntax for the while true loop. Syntax while True: # Code block to be executed repeatedly The keyword “while” precedes the condition "True" in the loop's first declaration. This boolean value evaluates to True every time, so ... Read More

Haskell Program to get the successor of an integer number using library function

Akhil Sharma
Updated on 13-Mar-2023 15:00:32

555 Views

In Haskell, we can get the the successor of an integer number using library function like succ, addition and fromMaybe function. In the first example, we are going to use (succ number) function and in the second example, we are going to use addition while in third example, we are going to use (fromMaybe 0 (succMaybe x)) function. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It calls the succ function with the value and prints its ... Read More

Haskell Program to get the predecessor of an integer number using library function

Akhil Sharma
Updated on 13-Mar-2023 14:59:41

244 Views

In Haskell, we can use library function like pred, subtraction and fromMaybe to get the predecessor of an integer number. In the first example, we are going to use (pred number) function and in the second example, we are going to use subtraction while in third example, we are going to use (fromMaybe 0 (predMaybe x)) function. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It calls the pred function with the value and prints its predecessor ... Read More

Advertisements