Topic: Tech & EngineeringData

Last updated: February 27, 2019

#Brett Hoeft#ISYS 110-002#Ferris State University#Program that will write a random sequence of code 1-500 to a filedef main(): random_num() num_file()def random_num(): import random random.randint(1,501) #setting parameters for random number file fileOne=open(‘randomnumbers.txt’,’w’) #writing to the randomnumbers.txt file #file one is data containing the code for the random numbers try: generatedNum=int(input(“What is the desired number?”)) #asking user for desired amount of random numbers for iteration in range(1,generatedNum +1): #setting parameters for number if generated numbers to be display based on input num=random.randint(1,501) fileOne.write(str(num)+ ‘
‘) #writing file to display random numbers in vertical order using
except: print(“Please use a value greater than one”) #error for wrong input fileOne.close()def num_file(): fileOne= open(‘randomnumbers.txt’,’r’) #reading number file to be displaye within randomnumbers file overalltotal=0 #setting to value zero to have display of random number runtotal=0 line = fileOne.readline() while line !=”: showNum=int(line) overalltotal+=showNum line = fileOne.readline() #reading data that has been generated print(str(showNum)) #displaying the interger produced by show number runtotal+=1 print(“Running total of randoms numbers are:”, overalltotal) # displaying total of random generated numbers average=overalltotal/runtotal #formula to calculate the average of values #displaying average of numbers generated = total/ print(“Average of the specified numbers are”,average) fileOne.close()main()

x

Hi!
I'm Piter!

Would you like to get a custom essay? How about receiving a customized one?

Check it out