Importing modules in Python

Importing modules in Python can be done easily. import module will import a module and then allow you to reference its objects — values, functions and classes, for example — using the module.name syntax. In the above example, the random module is imported, which contains the randint function. So by importing random you can call … Read more

Using loops within functions

python

In Python function will be returned as soon as execution hits “return” statement. Learn about Using loops within functions. In Python function will be returned as soon as execution hits “return” statement. Using loops within functions: Return statement inside loop in a function In this example, function will return as soon as value var has … Read more

String Methods

python

Python’s string type provides many functions that act on the capitalization of a string. Learn more about String Methods in this useful guide. Changing the capitalization of a string Python’s string type provides many functions that act on the capitalization of a string. These include: str.casefold str.upper str.lower str.capitalize str.title str.swapcase With unicode strings (the … Read more

PYTHON String Formatting

When storing and transforming data for humans to see, string formatting can become very important. Python offers a wide variety of python string formatting methods which are outlined in this topic Basics of Python String Formatting foo = 1bar = ‘bar’baz = 3.14 You can use str.format to format output. Bracket pairs are replaced with … Read more

Decorators Function in Python

Python Tutorials

Decorators function in Python are used to wrap or decorate any kind of function. Learn how to use them here. Parameter Details Decorators Function in Python Decorator functions are software design patterns. They dynamically alter the functionality of a function, method, or class without having to directly use subclasses or change the source code of … Read more

Classes in Python

python

Python offers itself not only as a popular scripting language, but also supports the object-oriented programming paradigm. Classes in Python describe data and provide methods to manipulate that data, all encompassed under a single object. Furthermore, classes allow for abstraction by separating concrete implementation details from abstract representations of data. Code utilizing classes is generally … Read more

Metaclasses in Python

Python Tutorials

Metaclasses in Python allow you to deeply modify the behaviour of Python classes (in terms of how they’re defined, instantiated, accessed, and more) by replacing the type metaclass that new classes use by default. Metaclasses in Python: Basic Metaclasses When type is called with three arguments it behaves as the (meta)class it is, and creates … Read more

Partial functions in Python

What if you could define an abstract function and specialize it in order to create different versions of it? Thinks it as a sort of function Inheritance where you bind specific params to make them reliable for a specific scenario. Partial functions in Python perform this function easily. Param details ythe exponent raise the function … Read more

Functions in Python

Python Tutorials

Functions in Python provide organized, reusable and modular code to perform a set of specific actions. Functions simplify the coding process, prevent redundant logic, and make the code easier to follow. This topic describes the declaration and utilization of functions in Python. Parameter Details arg1, …, argN Regular arguments *args Unnamed positional arguments kw1, …, … Read more

Getting Started with Java Language

Java SE Version Code Name End-of-life (free1) Release Date Java SE 10 (Early Access) None future 2018-03-20 Java SE 9 None future 2017-07-27 Java SE 8 Spider future 2014-03-18 Java SE 7 Dolphin 2015-04-14 2011-07-28 Java SE 6 Mustang 2013-04-16 2006-12-23 Java SE 5 Tiger 2009-11-04 2004-10-04 Java SE 1.4 Merlin prior to 2009-11-04 2002-02-06 … Read more

Functional Programming in Python

Python Tutorials

Functional Programming in Python decomposes a problem into a set of functions. Ideally, functions only take inputs and produce outputs, and don’t have any internal state that affects the output produced for a given input.below are functional techniques common to many languages: such as lambda, map, reduce. Functional Programming in Python: Lambda Function An anonymous, … Read more

Defining functions with list arguments

python

Section 34.1: Function and Call Lists as arguments are just another variable: def func(myList):for item in myList:print(item) and can be passed in the function call itself: func([1,2,3,5,7])12357 Or as a variable: aList = [‘a’,’b’,’c’,’d’]func(aList)abcd Must Read Python Interview Questions 165+ Python Interview Questions & Answers 200+ Python Tutorials With Coding Examples Python Language Basics Tutorial … Read more

Iterables and Iterators

Python Tutorials

Iterables and Iterators are different types of objects involved in python programming. Learn more about Iterables and Iterators and generator here. Difference between generator, Iterables and Iterators An iterable is an object that can return an iterator. Any object with state that has an iter method and returns an iterator is an iterable. It may … Read more

Files & Folders I/O

python

When it comes to storing, reading, or communicating data, working with the files of an operating system is both necessary and easy with Python. Unlike other languages where file input and output requires complex reading and writing objects, Python simplifies the process only needing commands to open, read/write and close the file. This topic explains … Read more

os.path Module

This os.path module implements some useful functions on pathnames. The path parameters can be passed as either strings, or bytes. Applications are encouraged to represent file names as (Unicode) character strings. Join Paths To join two or more path components together, firstly import os module of python and then use following: import osos.path.join(‘a’, ‘b’, ‘c’) … Read more

Basic Input and Output

python

Basic Input and Output functions can be easily performed by using Python. Here is all you need to know about how to perform basic tasks. Basic Input and Output: Using the print function Python 3.x Version ≥ 3.0 In Python 3, print functionality is in the form of a function: print(“This string will be displayed … Read more

Tuple in Python

A tuple in Python is an immutable list of values. Tuples are one of Python’s simplest and most common collection types, and can be created with the comma operator (value = 1, 2, 3). Tuple in Python Syntactically, a tuple is a comma-separated list of values: t = ‘a’, ‘b’, ‘c’, ‘d’, ‘e’ Although not … Read more

Filter in Python

python

If you are looking for the right resource to learn about the basics and application of Filter in Python, you have landed the right place. Learn how. Parameter functioniterable Details callable that determines the condition or None then use the identity function for filtering (positional-only) iterable that will be filtered (positional-only) Basic use of Filter … Read more

Python Heapq Module

python

To find the largest items in a collection, Python heapq Module has a function called nlargest, we pass it two arguments, the first one is the number of items that we want to retrieve, the second one is the collection name: Python Heapq Module: Largest and smallest items in a collection To find the largest … Read more

Linked List Node

python

Linked List Node in Python is another important aspect to learn when it comes to doing programming in Python. Learn more here. Write a simple Linked List Node in python A linked list is either: the empty list, represented by None, or a node that contains a cargo object and a reference to a linked … Read more