How to Calculate Powers of 2 in Python
The challenge
Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging …
320 articles about python development, tools, and best practices
Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging …
Create a function that takes in an id and returns the planet name.
Option 1:
def get_planet_name(id): …
Read Article →
If you want to create a directory in Python, but only if it doesn’t exist, you have the following option.
from …
Read Article →
Complete the square sum function so that it squares each number passed into it and then sums the results together.
For example, for [1, …
We want an array, but not just any old array, an array with contents!
Write a function that produces an array with the numbers `` to N-1 …
The below Python code will create a connection to a MSSQLServer instance, and retrieve data from it back into a variable called tblResults.
# use …
Read Article →
Numbers ending with zeros are boring.
They might be fun in your world, but not here.
Get rid of them. Only the ending ones.
1450 -> …
Read Article →
When you have performance problems in your Python application, you can use a Profiler to help you.
Your first option is to run …
Read Article →Given a non-negative integer, 3 for example, return a string with a murmur: "1 sheep...2 sheep...3 sheep...". Input will …
If you have a CommandLine application (CLI) written in Python, you have a number of ways that you can take arguments from the user.
You could take the …
Read Article →Python provides the ability to create Translation Tables.
our_text = "This is an example of some text"
translation_table = …
Read Article →
Let’s take the following string:
numbers = "this 1 2 3 4 5 is not a 8 9 10"
How can we sum up all the numbers in this string? …
Read Article →