Found 26504 Articles for Server Side Programming

Namespaces and Scoping in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:28:56

534 Views

Variables are names (identifiers) that map to objects. A namespace is a dictionary of variable names (keys) and their corresponding objects (values).A Python statement can access variables in a local namespace and in the global namespace. If a local and a global variable have the same name, the local variable shadows the global variable.Each function has its own local namespace. Class methods follow the same scoping rule as ordinary functions.Python makes educated guesses on whether variables are local or global. It assumes that any variable assigned a value in a function is local.Therefore, in order to assign a value to a global variable within a ... Read More

Locating Modules in Python

gireesha Devara
Updated on 01-Sep-2025 11:22:04

1K+ Views

Locating modules in Python refers to the process of how Python finds and loads a module into our current program when we are trying to import it. Python's standard library comes with a large number of modules that we can use in our programs with the import statement. Locating Modules in Python When you write an import statement like import mymodule, the Python interpreter searches for the module in the following sequences: The current directory: Python first checks the directory of the current script. PYTHONPATH Environment Variable: If the module isn't ... Read More

The import Statements in Python

gireesha Devara
Updated on 01-Sep-2025 11:37:47

5K+ Views

In Python, accessing and using the code from one module to another module is possible by the importing process. That means, you can use any Python source file as a module by executing an import statement in some other Python source file. This is done using the import statement in Python. The import Statement When the Python interpreter encounters an import statement, it imports the module if the module is present in the search path. A search path is a list of directories that the interpreter searches before importing a module. This import operation in Python internally uses the built-in ... Read More

The return Statement in Python

Sarika Singh
Updated on 19-Dec-2022 12:09:39

3K+ Views

The return statement in python is an extremely useful statement used to return the flow of program from the function to the function caller. The keyword return is used to write the return statement. Since everything in python is an object the return value can be any object such as – numeric (int, float, double) or collections (list, tuple, dictionary) or user defined functions and classes or packages. The return statement has the following features - Return statement cannot be used outside the function. Any code written after return statement is called dead code as it will never ... Read More

The Anonymous Functions in Python

gireesha Devara
Updated on 01-Sep-2025 11:16:16

2K+ Views

The Anonymous Functions in Python Python creates function objects when you write a lambda expression using the lambda keyword. These functions are called anonymous functions because they are not defined using the standard def keyword. These functions are useful when you need a small, single-line function to execute a single expression. Features of Anonymous Functions The following are the features of Anonymous Functions: It can be used wherever a function object is needed in your program, without assigning a name. A lambda function can take any number of arguments but can only ... Read More

Variable-length arguments in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:19:40

6K+ Views

You may need to process a function for more arguments than you specified while defining the function. These arguments are called variable-length arguments and are not named in the function definition, unlike required and default arguments.SyntaxSyntax for a function with non-keyword variable arguments is this −def functionname([formal_args, ] *var_args_tuple ): "function_docstring" function_suite return [expression]An asterisk (*) is placed before the variable name that holds the values of all nonkeyword variable arguments. This tuple remains empty if no additional arguments are specified during the function call.Example Live Demo#!/usr/bin/python # Function definition is here def printinfo( arg1, *vartuple ): "This prints a variable passed arguments" ... Read More

C program for file Transfer using UDP?

Arnab Chakraborty
Updated on 29-Jan-2020 12:18:08

1K+ Views

Data can be shifted between two computers implementing Socket programming in C.In same case, files can easily be sent implementing User Datagram Protocol(UDP) and a simple client/server.Security − Handled by encryption.Protocol − UDPEncryption − XOR encryptionAlgorithmThe server is started and waited for filename.A filename is sent by the client.This filename is received by the server. If file is present, server starts reading file and is continued to send a buffer filled with file contents encrypted until and unless file-end is reached.End of File is marked by EOF.File is received as buffers until and unless EOF is received. After that it ... Read More

Binomial Heap in C++?

Arnab Chakraborty
Updated on 29-Jan-2020 12:10:57

499 Views

Binomial Heap is defined as an extension of Binary Heap that provides faster merge or union operation together with other operations provided by Binary Heap.A Binomial Heap is treated as a collection of Binomial Trees.What is a Binomial Tree?A Binomial Tree of order k can be built by taking two binomial trees of order k-1 and treating one as leftmost child or other.A Binomial Tree of order k has below properties.The number of nodes of Binomial Tree has exactly 2k.The depth of Binomial Tree is k.There are exactly kCi nodes at depth i where i = 0, 1, . . ... Read More

Binary Tree to Binary Search Tree Conversion using STL set C++?

Arnab Chakraborty
Updated on 29-Jan-2020 12:11:48

728 Views

In case of a given Binary Tree, convert it to a Binary Search Tree in such a way that keeps the original structure of Binary Tree intact.Sets of C++ STL will be used by this solution instead of array based solution.ExamplesExample 1Input     11     /  \    3    8 /     \ 9 5Output     9    /   \   5     11  /        \ 3        8Example 2Input      11      /   \     31    16    /        \  21 ... Read More

Required arguments in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:14:12

8K+ Views

Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −Example Live Demo#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme()OutputWhen the above code is executed, it produces the following result −Traceback (most recent call last): File "test.py", line 11, in printme(); TypeError: ... Read More

Advertisements