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. 🔥
Also you can use...
ReplyDeletefor x in range(1000000000000000):
10**x