Skip to content

Instantly share code, notes, and snippets.

@kaubu
Last active September 10, 2022 07:14
Show Gist options
  • Save kaubu/8dce84fc4811aef5e2c59b9bd6ad29c4 to your computer and use it in GitHub Desktop.
Save kaubu/8dce84fc4811aef5e2c59b9bd6ad29c4 to your computer and use it in GitHub Desktop.
Calculate a number that is doubled over and over
base = float(input("What is the base number? "))
double = int(input("How many times do you wish to double it? "))
for i in range(1, double+1):
doubled_base = base * 2
if doubled_base.is_integer():
print(f"\n{doubled_base:.0f}\n\t\t(^ Number {i})")
else:
print(f"\n{doubled_base:.1f}\n\t\t(^ Number {i})")
base = doubled_base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment