How to do Binary Addition in Python
The challenge
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before or after the …
Read Article →329 articles about python development, tools, and best practices
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before or after the …
Read Article →You have successfully written your pandas Dataframe to an Excel file, but when you open it, all the columns are squashed up against each other.
There …
Read Article →You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their …
Read Article →Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or …
Read Article →Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same …
Given a string, replace every letter with its position in the alphabet.
If anything in the text isn’t a letter, ignore it and …
Read Article →You are given a string of space-separated numbers and have to return the highest and lowest number.
Example:
high_and_low("1 2 3 4 …
Read Article →
Implement a difference function, which subtracts one list from another and returns the result.
It should remove all values from list a, …
Given an integer numRows, return the first numRows of Pascal’s triangle.
In Pascal’s triangle, each number is the sum of the …
Read Article →Create a function that takes 2 nonnegative integers in form of a string as an input, and outputs the sum (also as a string):
Example: ( …
Read Article →Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently they can be guessed due …
Read Article →You are given an m x n binary matrix grid. An island is a group of 1‘s (representing land) connected 4-directionally (horizontal or …
Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design. You will be given a …
Read Article →I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 …
Read Article →Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). …
Read Article →Python comes with a built-in method on all String types, by calling lower() on a String, you can immediately lower the case of that String.
If you have a decimal number, and want to get it’s binary value, you can use the built-in bin method.
decimal = 32
binary = bin(decimal)
# …
Read Article →
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the …
Read Article →Given a non-negative integer, return an array / a list of the individual digits in order.
Examples:
123 => [1,2,3]
1 => [1] …
Read Article →
Create a Circular List
A circular list is of finite size, but can infititely be asked for its previous and next elements. This is …
Read Article →Don Drumphet lives in a nice neighborhood, but one of his neighbors has started to let his house go. Don Drumphet wants to build a wall …
Read Article →Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing …
Read Article →Remove a exclamation mark from the end of string. You can assume that the input data is always a string, no need to verify it.
Create a function close_compare that accepts 3 parameters: a, b, and an optional margin. The function should return whether a is lower …