Monday, 8 February 2021

Practical No: 11: - Create a binary file with 10 random numbers from 1 to 40 and print those numbers.

'''Practical No. 11: Create a binary file with 10 random numbers from 1 to 40 and print

those numbers.'''


import pickle,random

N=[]

f=open("sps.txt","wb")

for i in range(10):

    N.append(random.randint(1,40))

pickle.dump(N,f)

f.close()

print("File Created:")

print("Content of File:")

f=open("sps.txt","rb")

data=pickle.load(f)

for i in data:

    print(i)

f.close()





 





No comments:

Post a Comment