- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Karthikeya Boyini has Published 2383 Articles
karthikeya Boyini
437 Views
If you have binary numbers as strings, you can convert them to ints first using int(str, base) by providing the base as 2. Then add the numbers like you'd normally do. Finally convert it back to a string using the bin function. For example, a = '001' b = '011' ... Read More
karthikeya Boyini
239 Views
Similar to the if statement syntax, if your while clause consists only of a single statement, it may be placed on the same line as the while header. Here are the syntax and example of a one-line for loop:for i in range(5): print(i)This will give the output:0 1 2 3 ... Read More
karthikeya Boyini
681 Views
You can put comments anywhere in an if...elif...else statement, ie before each of these blocks or within each of these blocks. Note that you cannot put multiline comments before elif and else blocks though, as these comments are actually strings which imply a break in the whole construct. For example, ... Read More
karthikeya Boyini
784 Views
If you want to get an inversion of only first 16 bits of a number, you can take a xor of that number with 65535(16 1s in binary). Forgetting a 2s complement, just add one to the result. For example, Examplea = 3 # 11 in binary b = (a ... Read More
karthikeya Boyini
1K+ Views
Python and javascript both have different representations for a dictionary. So you need an intermediate representation in order to pass data between them. The most commonly used intermediate representation is JSON, which is a simple lightweight data-interchange format.ExampleThe dumps function converts the dict to a string. For example, import json ... Read More
karthikeya Boyini
2K+ Views
If you have a dictionary of the following format:{ 'KEY1':{'name':'foo', 'data':1351, 'completed':100}, 'KEY2':{'name':'bar', 'data':1541, 'completed':12}, 'KEY3':{'name':'baz', 'data':58413, 'completed':18} }And you want to sort by the key, completed within each entry, in a ascending order, you can use the sorted function with a lambda that specifies which key ... Read More
karthikeya Boyini
533 Views
Every class is an object. It's an instance of something called a metaclass. The default metaclass is typed. You can check this using the is instance function. For example, class Foo: pass foo = Foo() isinstance(foo, Foo) isinstance(Foo, type)This will give the output:True TrueA metaclass is not part ... Read More
karthikeya Boyini
821 Views
Like the Trapezoidal Rule, Simpson’s 1/3rd rule is also used to find the integral value from the range a to b. The main difference between trapezoidal and the Simpson’s 1/3rd rule is, in the trapezoidal rule, the whole sections are divided into some trapezoids, but in this case, each trapezoid ... Read More
karthikeya Boyini
2K+ Views
Lucky numbers are some special integer numbers. From basic numbers, some special numbers are eliminated by their position. Instead of their value, for their position, the numbers are eliminated. The numbers which are not deleted, they are the lucky numbers.The number deletion follows some rule. At first, every second number ... Read More
karthikeya Boyini
1K+ Views
A sequence of words is given, there is a limit on the number of characters for each line. By putting line breaks, in such a way that lines are printed clearly.The lines must be balanced, when some lines have lots of extra spaces and some lines are containing a small ... Read More