Add Character to Specific Position in String Using Python

Vikram Chiluka
Updated on 25-Aug-2023 00:51:31

67K+ Views

In this article, we will learn how to add a character to a specific position in a string in Python. Methods Used The following are the various methods to accomplish this task − Using the '+' operator Using join() function Using format() function Method 1: Using the '+' operator We can concatenate strings and characters using the symbol "+" at the required positions. Adding Character at the End of a String Algorithm: Following are the Algorithms/steps to be followed to perform the desired task. − Create a variable to store an input string. Use the "+" operator ... Read More

What is Negative Indexing in Python

AmitDiwan
Updated on 25-Aug-2023 00:33:24

41K+ Views

Negative Indexing is used to in Python to begin slicing from the end of the string i.e. the last. Slicing in Python gets a sub-string from a string. The slicing range is set as parameters i.e. start, stop, and step. Syntax Let us see the syntax − #slicing from index start to index stop-1 arr[start:stop] # slicing from index start to the end arr[start:] # slicing from the beginning to index stop - 1 arr[:stop] # slicing from the index start to index stop, by skipping step arr[start:stop:step] If the values above are in negative, that ... Read More

Plot an Array in Python Using Matplotlib

Rishikesh Kumar Rishi
Updated on 25-Aug-2023 00:24:57

59K+ Views

To plot an array in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create two arrays, x and y, using numpy.Set the title of the curve using title() method.Plot x and y data points, with red color.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.array([5, 4, 1, 4, 5]) y = np.sort(x) plt.title("Line graph") plt.plot(x, y, color="red") plt.show()Output

Find Client IP Address in Python

Pradeep Elance
Updated on 25-Aug-2023 00:22:01

61K+ Views

In this tutorial, we are going to find the IP address of the client using the socket module in Python. Every laptop, mobile, tablet, etc.., have their unique IP address. We will find it by using the socket module. Let's see the steps to find out the IP address of a device.Algorithm Import the socket module. Get the hostname using the socket.gethostname() method and store it in a variable. Find the IP address by passing the hostname as an argument to the socket.gethostbyname() method and store it in a variable. Print the IP address. Let's write code for the above ... Read More

Change User Password in Ubuntu

Satish Kumar
Updated on 24-Aug-2023 20:47:16

3K+ Views

Introduction If you are a Linux user, there is no doubt that you have heard of Ubuntu OS. Ubuntu is an open-source operating system based on the Debian architecture and is one of the most popular distributions of Linux. It's user-friendly interface, and versatile nature makes it a great operating system for both personal and professional use. As with any operating system, password security in Ubuntu is of utmost importance. With cyberattacks increasing day by day, secure passwords are essential to keep your information safe from unauthorized access. This guide aims to simplify the process of changing your user password ... Read More

Change Sudo or Root Password in Ubuntu

Satish Kumar
Updated on 24-Aug-2023 20:45:55

13K+ Views

Introduction Ubuntu is a popular Linux operating system that gives users access to powerful tools for managing files, processes, and other system settings. One of the key features of Ubuntu is the ability to use "sudo" or "root" access to perform administrative tasks. This allows you to make changes to the system that would otherwise require special permissions. Sudo access is a type of temporary privilege escalation that allows a user to perform an action with administrative privileges. It requires the user's password before making any changes and is often used for one-time tasks like installing software. On the other ... Read More

Change SSH Port in Linux

Satish Kumar
Updated on 24-Aug-2023 20:45:03

676 Views

Introduction Secure Shell (SSH) is a protocol that provides a secure channel over an unsecured network in Linux systems. It is commonly used for remote logins, file transfers, and executing commands on a remote machine securely. SSH is an essential tool for Linux system administrators, developers, and users who access their machines remotely. Checking Current SSH Port Before we can proceed to changing the SSH port, it is important to know the current port number being used. By default, the SSH service listens on port 22. However, this is a well-known port and is often targeted by attackers. Therefore, it ... Read More

Change Speed and Duplex of Ethernet Card in Linux with ethtool

Satish Kumar
Updated on 24-Aug-2023 20:43:43

7K+ Views

Introduction Ethernet cards, also known as network interface cards (NICs), are hardware components that allow computers to connect to networks. These cards enable data transmission between devices by converting digital signals from a computer into electrical signals that can be sent over the network's physical medium, such as copper wires or fiber-optic cables. Ethernet cards are essential for accessing the internet, file sharing and printing in a local network. Understanding Ethtool Command Definition and Functionality Ethtool is a Linux command-line utility that allows users to query and change various network interface card (NIC) settings. It provides detailed information about the ... Read More

Change Runlevels and Targets in Systemd

Satish Kumar
Updated on 24-Aug-2023 20:42:26

2K+ Views

SystemD is a system and service manager for Linux operating systems. It manages the boot process, system services, and provides a centralized way to manage processes. One of the key features of SystemD is its use of runlevels (targets) to define the state of the system at startup. Runlevels (targets) are a set of services and processes that are started or stopped depending on the current state of the system. Understanding how to change runlevels (targets) is an important skill for any Linux administrator. Understanding Runlevels (Targets) In the traditional Unix system, runlevels were used to determine which set of ... Read More

Change Root Password of MySQL or MariaDB in Linux

Satish Kumar
Updated on 24-Aug-2023 20:39:54

790 Views

Introduction As with any password, the root user password for a MySQL or MariaDB database should be changed regularly for security reasons. The root user has complete access and control over all databases and tables within the system, making it a prime target for any potential attacks. Regularly changing the root password can help prevent unauthorized access to your data, as well as provide an added layer of security against potential server breaches. Checking Current Root Password A root user is a powerful administrator account that has full access to the MySQL or MariaDB server. It is important to regularly ... Read More

Advertisements