Created
April 5, 2019 06:59
-
-
Save AnkDos/32e48e9407b1b1ee3aac55f99915d6f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created By Ankdos | |
# Program to print random number between range without using inbuilt function | |
import datetime | |
def push (mins , maxs , ms) : | |
ran = gen_rand(0,maxs-mins) | |
ms = mins + ran | |
if ms > maxs : | |
push(ms , mins ,maxs) | |
else : | |
return ms | |
def count_digs (nums) : | |
count = 0 | |
while nums > 0 : | |
nums = int(nums / 10) | |
count += 1 | |
return count | |
def gen_rand(mins , maxs) : | |
x = str(datetime.datetime.now()) | |
ms = int(x.split('.')[1]) | |
if maxs > mins : | |
if count_digs(mins) > 6 : | |
ms = push (mins , maxs , ms) | |
return ms | |
else : | |
if ms >= mins and ms <= maxs : | |
return ms | |
elif ms > maxs : | |
ms = ms % maxs | |
if ms < mins : | |
return mins | |
else : | |
return ms | |
elif ms < mins : | |
return mins | |
else : | |
return "Min's Greater than max" | |
print(gen_rand(1250000000,14000032456)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment