Skip to content

Instantly share code, notes, and snippets.

@shamikalashawn
Created February 6, 2017 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamikalashawn/1574bff3aa63f2dbcd90dcc3a7a9bb05 to your computer and use it in GitHub Desktop.
Save shamikalashawn/1574bff3aa63f2dbcd90dcc3a7a9bb05 to your computer and use it in GitHub Desktop.
The number entered is the exponent for the power of 2.
def powers_of_two(power):
num = 1
if power == 0:
return 1
elif power > 0:
for x in range(1,power+1):
num *= 2
return num
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment