Programming Articles

Found 25,467 articles

How can a Python function return a function?

Sarika Singh
Sarika Singh
Updated on 18-Mar-2026 19K+ Views

In Python, functions are treated as first-class objects, which means all functions in Python are treated like any other object or variable. You can assign a function to a variable, pass it as an argument to another function, return it from a function, or even store it in data structures like lists. One very useful feature in Python is that a function can return another function. This means you can define a function inside another function and return it as a result. This is used in advanced programming concepts like closures, decorators, and higher-order functions. Syntax Following ...

Read More

What are Python function attributes?

Tarun Chandra
Tarun Chandra
Updated on 18-Mar-2026 40 Views

In Python, everything is an object, and functions are no exception. Since functions are objects, they can have attributes — custom data attached to them, just like attributes on a class instance. This allows you to store metadata, counters, configuration, or any arbitrary data directly on a function. Function attributes are different from function parameters. Parameters are inputs passed during a function call, while attributes are persistent data stored on the function object itself. Syntax You can set and access function attributes using the dot (.) operator, or using setattr() and getattr() built-in functions − ...

Read More

C/C++ Ternary Operator

Narendra Kumar
Narendra Kumar
Updated on 18-Mar-2026 5K+ Views

The ternary operator (?:) in C/C++ is a shorthand for an if-else statement. It is the only operator in C/C++ that takes three operands, which is why it is called "ternary". Syntax (expression-1) ? expression-2 : expression-3 This operator returns one of two values depending on the result of an expression. If expression-1 evaluates to Boolean true, then expression-2 is evaluated and its value is returned as the final result. Otherwise, expression-3 is evaluated and its value is returned. Ternary Operator Flow condition ? ...

Read More

Anti Clockwise spiral traversal of a binary tree?

Arnab Chakraborty
Arnab Chakraborty
Updated on 18-Mar-2026 360 Views

Here we will see one interesting problem. We have a binary tree and we have to traverse it in an anti-clockwise manner. The traversal alternates between printing levels from right-to-left (starting from the top) and left-to-right (starting from the bottom), creating a spiral-like anti-clockwise pattern. For the binary tree shown below, the anti-clockwise traversal sequence is − 1, 8, 9, 10, 11, 12, 13, 14, 15, 3, 2, 4, 5, 6, 7 Binary Tree — Anti-Clockwise Traversal ...

Read More

A comma operator question in C/C++ ?

karthikeya Boyini
karthikeya Boyini
Updated on 18-Mar-2026 375 Views

The comma (, ) in C/C++ programming language has two contexts − As a separator − Used to separate variable declarations, function arguments, and initializer values. In this context, the comma is not an operator. As an operator − The comma operator is a binary operator that evaluates the first expression, discards its result, then evaluates and returns the value of the second expression. This operator has the lowest precedence of all C/C++ operators — even lower than the assignment operator. Syntax result = (expr1, expr2); // ...

Read More

Difference between %p and %x in C/C++

Nishtha Thakur
Nishtha Thakur
Updated on 18-Mar-2026 10K+ Views

Here we will see what are the differences between %p and %x in C or C++. The %p format specifier is used to print pointer values (memory addresses), while %x is used to print unsigned integers in hexadecimal format. Though pointers can also be displayed using %u or %x, the correct and portable way to print a pointer is %p. The visible difference is that %p prints with leading zeros and is platform-width aware (16 hex digits on 64-bit systems, 8 on 32-bit), while %x prints only the significant digits without padding. Syntax printf("%p", pointer); ...

Read More

Which one is the Python module to obfuscate javascript?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 18-Mar-2026 1K+ Views

You can use the jsmin module to minimize and obfuscate JavaScript code using Python. Minification removes whitespace, comments, and unnecessary characters from JavaScript files, reducing file size without changing functionality. Installing jsmin Install jsmin using pip − $ pip install jsmin Syntax Following is the basic syntax for using jsmin in Python − from jsmin import jsmin minified_code = jsmin(javascript_string) The jsmin() function takes a JavaScript source string as input and returns the minified version as a string. Minifying a JavaScript File To use jsmin in ...

Read More

Resource Reservation Protocol in Real-time Systems

Pranavnath
Pranavnath
Updated on 17-Mar-2026 893 Views

Resource Reservation Protocol (RSVP) is a network protocol used in real-time systems to reserve bandwidth and ensure quality of service (QoS) for time-critical applications. Operating at the transport layer, RSVP allows applications to request specific network resources before data transmission begins, guaranteeing predictable performance for multimedia and real-time communications. How RSVP Works RSVP uses a receiver-oriented approach where the destination device initiates resource reservation requests. The protocol establishes resource reservations through a two-phase process involving PATH and RESV messages that traverse the network path between sender and receiver. RSVP Resource Reservation Process ...

Read More

Move cmd command

Diksha Patro
Diksha Patro
Updated on 17-Mar-2026 3K+ Views

The move command in Microsoft Windows Command Prompt is a powerful utility for relocating files and folders from one location to another. This built-in command provides an efficient way to organize and manage your file system directly from the command line interface. The basic syntax of the move command follows this pattern: the command itself, followed by the source file or directory path, and then the destination path. When executed, it transfers the specified file or folder to the new location, removing it from the original position. How It Works The move command operates by transferring files ...

Read More

Performance metrics for mutual exclusion Algorithm

Way2Class
Way2Class
Updated on 17-Mar-2026 941 Views

Mutual exclusion is a fundamental concept in operating systems that ensures no two concurrent processes access the same critical section simultaneously. It prevents race conditions by allowing only one process to execute in the critical section at any given time, maintaining data consistency and system integrity. Performance Metrics for Mutual Exclusion To evaluate the effectiveness of mutual exclusion algorithms, four key performance metrics are used to measure their efficiency under different system conditions. Message Complexity The total number of messages required for a process to enter and exit the critical section. This metric measures the communication ...

Read More
Showing 1–10 of 25,467 articles
« Prev 1 2 3 4 5 2547 Next »
Advertisements