Python Split String Into List of Characters
To split a string into a list of characters, the “list()”, “extend()”, “List Comprehension”, and “for Loop” are utilized in the Python programs.
To split a string into a list of characters, the “list()”, “extend()”, “List Comprehension”, and “for Loop” are utilized in the Python programs.
To find the factorial of a number, the inbuilt “factorial()” function, “Recursion” function, “if-else” statement, and “numpy.prod()” function is used in Python
To get the current working directory, use the “os.getcwd()” function, while to change the current working directory the “os.chdir()” is used.
In Python, the “range()” function creates the sequence of numbers by specifying the upper and lower limit with the addition of step size value.
To remove or delete files and directories, the “os.remove()”, “os.unlink()”, “os.rmdir()” and “shutil.rmtree()” functions are used in Python.
To convert the list into a tuple, the “tuple()” function, “for loop”, and “unpacking list operator (*List, ) ” with a single comma are used.
To create an empty tuple, the “tuple()” function and empty parentheses are used in Python. For instance, “()” represents an empty tuple.
The “if-else” statement executes a block of code based on the specified condition. If the specified condition is true, then the if block will execute
To reverse the list element, the “reverse()” method is used in Python. The “reversed()” function also accepts the list and returns the reversed iterable object.
To sort the elements of a list in ascending or descending order, the “sort()” method and “sorted()” function is used in Python.
The “replace()” method in Python replaces the old substring value with a new substring value. By default, it will replace all the occurrences of a substring.
“while” loop executes the block of code until the condition remains “True”. It iterates infinite times if the increment/decrement value is not defined.
To sort a list of strings, the“sort()” and “sorted()” functions are used in Python. The sorting of data also varies using the key and reverse parameters
In Python, the “math.log10()” function of the “math” module is used to calculate the logarithm of a given positive number to base 10.
In Python, the hexadecimal to decimal conversion is carried out using the inbuilt “int()” function, “literal_eval()”, “while” loop, and “dictionary”.
To copy files and directories in Linux, we can use the command-line interface using the cp command or the GUI method. For a detailed explanation, read this post.
The grep command can be used to find the words in the files of Linux. The words can be found in the current directory and its sub-directories.
In Linux, the purpose of the ifconfig command is to configure the network interfaces, specifically those associated with Kernel modules
The uname command is used in Linux to display the basic information of the computer, including kernel name, hostname, kernel version, and processor type.
GRUB is the abbreviation of GRand Unified Bootloader and is a bootloader and a boot manager. GRUB plays a key role in the Boot process.
In Python, an inbuilt “input()” function is used to take the user input value and returns it in the form of a string by default.
To clear all the items of the dictionary, the “dict.clear()” function is used in Python. “del” keyword deletes the dictionary rather than just the items in it.
To convert float to int, the inbuilt functions such as “int()”, “math.floor()”, “math.ceil()”, “round()”, and “math.trunc()” are used in Python.
To convert integers into a string, the inbuilt “str()” function, “.format()” function, “f-string” method and “%s” operator are used in Python.
In Python, an inbuilt “len()” function, the “for loop”, and the “length_hint()” function is used to find the length of the list.
To start, stop & restart the services on Ubuntu, use any of these“systemctl”, “service”, and “init” command utilities. Read out this article to learn more.
To count files in directory, use the “ls [path] | wc -l”, “find [path] | -type f | wc -l”, “tree [path]”, and “rsync –stat –dry-run -a [path]” commands.
To update GRUB, open the terminal and execute the command “sudo update-grub”. GRUB must be updated to have a smooth performance of the system.
To set or change the hostname in Linux, use the command “sudo hostnamectl set-hostname [name]” or by changing the computer name in Sharing of Settings.
In Python, “string slicing”, “re.sub()”, “replace()”, and “List Data Structure” methods replace characters at a specific position of the string.
In Python, the “for” loop iterates on the range() function and operates on each element. The “range()” function must have a “stop” argument value
To create a new file in python, the open() function is used. It accepts two parameters: the complete path and the “x” character.
The “dict.keys()”, “List Comprehension”, “for loop with append()”, “Unpacking with *” and “itemgetter()“are used to convert dictionary keys to lists.
The “str()” function is used to return any input data type as a string. Data types, such as list, dict, etc., can be converted into a string using this function.
In Python, the index number is used to access the items of a Python tuple. The items of tuples are accessed individually and in the form of ranges.
In Python, the “len()” function, “not” operator, “not with strip()” and “not with isspace()” methods are used to check if the string is empty
In Python, the “len()” function, the “for loop with isinstance() function”, and the recursive function are used to calculate the dictionary’s length.
The “OR” operator in Python “if statement” is used to combine multiple conditions and filter out the information based on the specified conditions.
In Python, the “math.log2()” function of the “math” module returns the logarithm of the number to base 2. The input number must be greater than zero.
In Python, the “rand()”, “randint()”, and “np.empty()” functions create “1-D”, “2-D”, and “3-D” arrays with different random values.
In Python, the “np.dot()” function of the “Numpy” package is used to calculate the dot product of scalar, vectors, 1-D, and 2-D arrays.
In Python, the “cv2.imread()” function is used to read the image from the specified file. The image is displayed using another function, “cv2.imshow()”.
In Python, the “re.findall()” function of the “regex” module returns the non-overlapping pattern of the given string in the form of a list of strings.
Linux distributions are mostly managed through the terminal. In the terminal, different commands are typed. … Read More
To install Linux Mint 21 from USB, first, download the iso file of Linux Mint 21, make the USB bootable with the downloaded iso file, and finally install it on the computer.
To get the GUI for the Ubuntu server, install the GNOME desktop environment using the command “sudo apt install ubuntu-desktop -y”
Some of the most common usages of the apt command in Ubuntu are updating and … Read More
If you are wondering whether Ubuntu is Debian based or looking for the key similarities and differences between them. Then read this article for more details.
To clear apt-cache and reclaim precious disk space, use either “sudo apt clean -y” or “sudo apt autoclean -y” in Linux distributions.
Python provides a built-in function named “set.add()” that adds a new element to a set. The set.add() function accepts exactly one argument.
The “math.atan()” function takes a numeric value and returns the inverse tangent of the given number in radians (within the range of “-Pi/2” to “Pi/2”).
First, install the VirtualBox on Linux, and download the Windows 10 iso. Then create a machine on VirtualBox and run it to install Windows 10
The “Fibonacci series” is created using the “for loop” iteration of any user-defined range. The Fibonacci series is generated by adding the previous two numbers.
In Python, the pillow module is used for multiples operation on digital images like cropping, filtering, drawing and enhancing, etc
In Python, the “math.ceil()” function takes positive or negative numeric values as arguments and rounds off the given numbers to the nearest integer.
To get the length of a Python string, a built-in function named “len()” or a user-defined function with “for loop” or “if-else” statements is used.
To create a Python list of dictionaries, place all the dictionaries within the square bracket using the comma-separated syntax
In Python, the “append()” function, “DataFrame.loc” and “pandas.concat()” functions are used to add or insert rows to pandas DataFrame.
The “DataFrame.reset_index()” resets any pandas DataFrame. The index of DataFrame is arranged according to the default index or the user-defined index
The “sort_values()” functions with “default parameter”, “descending order”, and “multiple columns” are used to Sort DataFrame by Column in Pandas
Run the command “systemctl list-units –type=service –state=running” or “service –status-all | grep ‘\[ + \]’” to check the running service on Linux.
To install mangohud on Ubuntu, run the command “sudo apt install mangohud -y” in the terminal of Ubuntu because it comes in its default repository
To install pgAdmin on Ubuntu, run the command “sudo apt install pgadmin4 -y” in the terminal to install both web and desktop modes.
The error “The following packages have unmet dependencies” is invoked if dependencies are broken, the repository is corrupted, or packages are held back
The “Unable to correct problems, you have held broken packages” occurs when apt repository isn’t updated, has broken dependencies, or the system holds packages.
The “sudo: no tty present and no askpass program specified” issue occurs when the sudo is used but password is not read. It is fixed by the NOPASSWD settings
The “mount point does not exist” issue is when declaring a mount point but the directory does not exist and is fixed by making that directory before mounting.
The “temporary failure resolving archive.ubuntu.com” issue occurs when the system has internet issues, or the DNS name server is missing.
The “json.dumps()” function of the json module converts the value of the dictionary into JSON. The value is stored in “keys” and then converted into JSON.
In Python, the pandas “iterrows()” function iterates over the DataFrame rows and performs user-defined operations on them.