special python programs By Hashir Ahmad

 2.  Randint Finder Program

NOTE : First create a file named "randint info.txt".

from random import randint
MyChoice = int(input('Enter desired number: '))
times=0
main = randint(1,10000)
while True:
    if main==MyChoice:
        break
    else:
        main=randint(1,100000)
        print(main)
        times+=1
        #with open('a.txt','a') as f:
            #f.write(str(main))
print(f'It took {times} times to reach {main}')
with open('randint info.txt','a') as f:
    f.write('\n'+str(times)+' '+str(main))
    if times>250000:
        f.write(' ThisTookMuchTime.')
   
#with open('a.txt','a') as f:
    #f.write(f'\nFOR {main}\n')
a=input('Wanna show doc? (enter or /): ')
if a == '':
    with open('randint info.txt') as f:
        print('\n'+f.read())
b=input('waiting ... ')

Comments

Popular posts from this blog

Advance Calculator Made For Mathematicans and Coders | Made with Python

My Projects

Functions Module