Category: Python

Python

argmax and argmin

argmax and argmin

argminxf(x) is the value of x for which f(x) attains it’s minimum. argmaxxf(x) is the value of x for which f(x) attains it’s maximum. In Python ARGMIN AND ARGMAX returns Indices of the minimum...

Comparing strings in python

Comparing strings in python

Comparing strings is a common job in programming. We can compare two strings with a == operator. We can check the opposite with the non-equality != operator. The operators return a boolean True or...

Arrays in Python

Arrays in Python

Simply an array is a group of related data items that share a common name. Arrays are of sequence types and behave very much like lists. The major difference is the elements of a...

Python time strftime() method

Python time strftime() method

The method strftime() converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a string as specified by the format argument. If t is not provided, the current time...

Creating a simple XML file using python

Creating a simple XML file using python

These days, the most popular (and very simple) option is the ElementTree API, which has been included in the standard library since Python 2.5. The available options for that are: ElementTree (Basic, pure-Python implementation...

Typecasting in python

Typecasting in python

Casting is when you convert a variable value from one type to another. This is, in Python, done with functions such as int() or float() or str(). The various casting methods that are in...

Absolute path python

Absolute path python

os.path.abspath makes sure a path is absolute. In the following example we are iterating through a directory and printing absolute path of each file in that directory. Example Output

Modules(saving python code in files)

Modules(saving python code in files)

Python code typed on console for practice, other than this we can also save our code to various files. Step 1: In the following example we have created testfile.py(.py is python file extension) in...