Sign in


You may have used the ifconfig command in your Linux terminal to understand the various network configurations on your system.

The ifconfig command displays the hardware address (HWaddr) and network address (inet addr) for your Ethernet or WiFi connection.

the ifconfig command does not display your public IP address (if public and private are different). To do this you can simply do a google search: what is my IP address, it will show you your public IP address.

In a Linux terminal, you can use the following command to find out your IP address:

public IP:

READ MORE:


Method1: count()

Using the count() function you will get the number of one element in an array in python. It is a built-in function in python.

list = [1,9,5,3,9,2,6,9,9,0,9]

count = list.count(9)

print(‘The count of element: 9 is ‘, count)

Output:

The count of element: 9 is 5

Method2:

READ MORE:


Find the position of an element in a list using the index() method. In python, Index() method returns the position of an element in a list.

Let’s see an example of it:

list = [1,2,3,7,8,5]

print(list.index(3))

Output:

2

READ MORE:


“Res” or “RES” has no inherent meaning in Python. If you’ve seen this in any part of Python code, maybe in someone’s answer to a question, then it’s probably just the variable name the author chose. It’s often used as an abbreviation for “result” — people sometimes do things like:

READ MORE:


you can add an int to the end of a string with the help of type conversion.

In this example, we simply convert the int data type to string data type using type conversion and adding it to the appropriate position.

Steps:

step1: take a string data type.

step2: take an int data type.

step3: convert the int into the string using type conversion.

step 4: add the string and int and assign to a variable.

step5: print the variable.

Example:

READ MORE:


How to Check Python Version in Linux

Most modern Linux distributions come with Python pre-installed.

To access a command line or terminal in Linux using

Ctrl-Alt-T, Ctrl-Alt-F2

Just open a terminal window and enter the following:

python — version

How to Check Python Version in Windows

READ MORE:


You want to print a number with only two decimal places in python.

print only two decimal places by using.

  1. Format method
  2. % formatting
  3. round method

and etc.

Let’s see an example of it.

By using Format Method:

READ MORE:

shubham

Works at khk MATLAB solution(2020-present)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store