
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
2K+ Views
When it is required to convert binary code to gray code, a method is defined that performs the ‘xor’ operation.Below is the demonstration of the same −Example Live Demodef binary_to_gray_op(n): n = int(n, 2) n ^= (n >> 1) return bin(n)[2:] gray_val = input('Enter the binary ... Read More

AmitDiwan
1K+ Views
When it is required to convert gray code to binary code, a method is defined, that checks to see if the number is 0 or not.Below is the demonstration of the same −Example Live Demodef flip_num(my_nu): return '1' if(my_nu == '0') else '0'; def gray_to_binary(gray): binary_code = "" ... Read More

AmitDiwan
423 Views
When it is required to generate gray codes with the help of recursion, a method is defined, that creates an empty list and appends values 0 and 1 to it. Multiple ‘for’ loops are used to generate the gray code within the function.Below is the demonstration of the same −Example Live ... Read More

AmitDiwan
417 Views
When it is required to clear the rightmost bit of a number which was previously set, the ‘&’ operator can be used.Below is the demonstration of the same −Example Live Demodef clear_right_bit(my_val): return my_val & (my_val-1) n_val = 6 print("The vlaue of n is :") print(n_val) print("The number after unsetting ... Read More

AmitDiwan
386 Views
When it is required to search the frequency of a number in a list, a method is defined, that takes a list and the number. It iterates through the list, and every time the number is encountered, the counter is incremented.Below is the demonstration of the same −Example Live Demodef count_num(my_list, ... Read More

AmitDiwan
2K+ Views
When it is required to determine the Pythagorean triplets within a given range, a method is defined, that helps calculate the triplet values.Below is the demonstration of the same −Example Live Demodef pythagorean_triplets(limits) : c, m = 0, 2 while c < limits : for n in range(1, ... Read More

AmitDiwan
1K+ Views
When it is required to implement Euler’s number, a method is defined, that computes the factorial.Another method is defined that find the sum of these factorial numbers.Below is the demonstration of the same −Example Live Demodef factorial_result(n): result = 1 for i in range(2, n + 1): ... Read More

AmitDiwan
549 Views
When it is required to print the numbers in a given range without using any loop, a method is defined, that keeps displays numbers from higher range by uniformly decrementing it by one after every print statement.Below is the demonstration of the same −Example Live Demodef print_nums(upper_num): if(upper_num>0): ... Read More

AmitDiwan
681 Views
When it is required to convert a nested tuple into a customized key dictionary, the list comprehension can be used.Below is the demonstration of the same −Example Live Demomy_tuple = ((6, 'Will', 13), (2, 'Mark', 15), (9, 'Rob', 12)) print("Thw tuple is : ") print(my_tuple) my_result = [{'key': sub[0], ... Read More

AmitDiwan
317 Views
When it is required to flatten tuple of a list to tuple, a method is defined, that takes input as tuple.The tuple is iterated over, and the same method is called on it over and over again until the result is obtained.Below is the demonstration of the same −Example Live Demodef ... Read More