Skip to main content


Python - numpy sequence of 10, 100, 1000


I was wondering what if I could create sequence in 10, 100, 1000 .... an so on... But as always first time of coding is never perfect, there has to be an error...! And along with error comes cheating...
Therefore also done some cheating in the code in the "step" section. Not sure if there is a better way to do it or I am by chance on the right track....

The only condition of this code to run perfectly is if you choose "stop" numbers in 10s, - 100000s.
But you change to number like say.... 987354321 then there is a problem...

But in the end all is well.

If posses better code then this one kindly comment below. Else just play along.

Long story short Here is the code:-

>>> import numpy as n
>>> start = 1
>>> stop = 1000000000000000
>>> step = len(str(stop))
>>> x = n.geomspace(start,stop,step)
>>> for i in x:
 print(int(i))

 
1
10
100
1000
10000
100000
1000000
10000000
100000000
1000000000
10000000000
100000000000
1000000000000
10000000000000
100000000000000
1000000000000000
>>> 

Hope you like the tutorial.

Try this code 🔴LIVE here
👉 https://code.sololearn.com/cTD5y1Nf6IT6/#py

Python is simple and fun to play with and yet very powerful. 🔥

Comments



🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍

Popular Posts

Python underline string, Python underline text, Underline python print

Python pip - Installing modules from IDLE (Pyton GUI) for python 3.7

Top 40 Python - String Processing in Python | Working with String in Python

Python Program - When was I born? / Date of Birth / MY BIRTHDAY (using Python3+)

Top 11 Essential Python Tips and Tricks





Subscribe to our Channel


Follow us on Facebook Page

Join our python facebook groups



Join us on Telegram