Programming: C and Python

C:
-
How to Reverse a String In C – Linux Hint
In string coding, string reversal is a crucial topic. There are also several methods for reversing a string, each of which has a different logic. This article will show you how to properly reverse a string to use several distinct approaches and reasoning with and without requiring any preset functions. Whenever the reversal of a string technique is applied in a particular unique input string, the text that a consumer would supply in a specific order will be completely reversed. In the instance beneath, different alternatives of reversing a string with C have been employed.
When implementing this guide, we have been working on Ubuntu 20.04 Linux system configured on Virtual Box. While working on a Linux system, we used to do most of our installations and queries on the terminal shell. Hence, open the terminal shell by a shortcut “Ctrl+Alt+T” or search it via an application search bar under the Activity area of the Ubuntu desktop. It is necessary to update your system first via the apt update query. It will ask you for the current user password to run the update. Hence, add a password and press Enter button.
-
Using Strings in C with Examples – Linux Hint
Strings are just a one-dimensional collection of characters with the null character ‘0’ at the end. On the other hand, a null-terminated string includes the characters that make up the string, succeeded by a zero. In this article, you will learn about how to deal with strings in Ubuntu 20.02 Linux system. Make sure you have GCC compiler installed in the system. Now open the terminal via Ctrl+Alt+T to get started.
-
How to Initialize a std::vector in C++ with Examples – Linux Hint
The full path of a file or folder from the root directory is specified by absolute path. In Python, the Current Working Directory is set to the directory location from where the python script executes. Many modules exist in python to get the Current Working Directory. How to get the Current Working Directory in Python is explained in this article.
-
Arrow -> Operator in C with Examples – Linux Hint
To understand the working of the Arrow operator, we need to understand what pointer is first. In C++, pointer exists as a mutable, which always refers to the location of some other mutable of almost any data kind, such as an int, char, or float, since we’ve already taught. A pointer to structures could be used likewise, with a pointer mutable pointing to the location of such a structure mutable. Throughout C/C++, the Arrow operator may be used to access items in Unions plus Structures. It can be used in conjunction with such a pointer variable that points to a structure and union. A negative sign precedes the greater than mark to construct the arrow operator. Throughout C or C++, the -> operator assigns the content of the mutable name to the structural or union mutable pointer name.
-
Bitwise operators in C with Examples – Linux Hint
The bitwise operators have been used to manipulate data only at the bit level. Bit-level computing would be done when you execute bitwise operations. It comprises two numbers, one of which is 0 and the other one is 1. It’s mainly used to speed up mathematical calculations. Inside the C language, we use several sorts of bitwise operators as below. Let’s discuss each one of them one by one. At the time of implementing this guide article, we have been working on Ubuntu 20.04 Linux system. We have successfully logged in from the system and installed the GCC compiler to compile C language code. Without a compiler, we are unable to execute our C script. After that, we have used the Ctrl+Alt+T key shortcut to open the terminal shell, as we have been doing every implementation and execution on a shell.
Python
-
How to Read YAML File in Python – Linux Hint
The full form of YAML is Yet Another Mark-up Language. This file format is very popular now to store serialized data that is human-readable. It is mainly used for configuration files, but it can be used for other purposes also. Different types of scalar data such as number, string, etc., and compound data such as list, the dictionary can be the content of this file. The extension of this fie is ‘.yaml’. Multiple modules exist in Python to read the YAML file. The use of the PyYAML module to read the YAML file in Python has shown in this tutorial.
-
How to Read Binary Files in Python – Linux Hint
The file that contains the binary data is called a binary file. Any formatted or unformatted binary data is stored in a binary file, and this file is not human-readable and is used by the computer directly. When a binary file is required to read or transfer from one location to another location, the file’s content is converted or encoded into a human-readable format. The extension of the binary file is .bin. The content of the binary file can be read by using a built-in function or module. Different ways to read binary files in Python have been shown in this tutorial.
-
How to Read from stdin in Python – Linux Hint
Take input from the user is an important part of any programming language. The output of the many programs depends on the standard input. The way of taking input from the user is different for different programming languages. Many ways exist in python to read from the standard input. The input() function is the most common way is to read from the standard input, which is a built-in function. The sys.stdin is another way is to read from the standard input the calls input() function internally. Python has another module named fileinput for reading the standard input. The input() function of this module can be used to read standard input or read content from one or more files. Different ways to read from the standard input in Python have been explained in this tutorial.
-
How to Get Current Working Directory in Python – Linux Hint
The file or folder name can be used with the full path or just mentioning the file or folder name only to use it in the script. The full path of a file or folder from the root directory is specified by absolute path. When the file name is used without the pathname in the script, then the Current Working Directory is assumed as the file’s pathname and is called the relative path. In Python, the Current Working Directory is set to the directory location from where the python script executes. Many modules exist in python to get the Current Working Directory. The ways to retrieve the Current Working Directory by using different modules in Python have shown in this tutorial.
-
Sort () V/s Sorted () – Linux Hint
Sorting is a technique to rearrange the elements or data either in ascending order or descending order. In Python programming, we can do sorting very easily with the help of the methods sort () and sorted ().
The sorted () and sort () methods arrange the elements either in ascending or descending order. Even both perform the same operations, but still, they are different.
For these tutorials, users must have some basic ideas about the list, tuples, and sets. We will be using some basic operations of these data structures to show a clear picture of sort () and sorted () built-in methods. And for this, I am using Python3, so if you are using Python2, then there might be some output difference.
-

- Login or register to post comments
Printer-friendly version- 2467 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is released
After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release.
|
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future Tech
The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world.
Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility.
|
today's howtos
|








.svg_.png)
Content (where original) is available under CC-BY-SA, copyrighted by original author/s.

Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago