-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomNumGen.py
More file actions
34 lines (21 loc) · 845 Bytes
/
RandomNumGen.py
File metadata and controls
34 lines (21 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
Lets user specify how many numbers should randomly be generated
'''
import random
def main():
#Local Variables
filename = ''
numberOfRandoms = 0
randomNumber = 0
#Get file name as input from the user
filename = input("Enter the name and type of the file to which results should be saved: ")
numberOfRandoms = int(input("Enter the amount of random numbers: "))
#--- Lab requests the output file have a certain name so this overwrites the users name
filename = "randomNumber.txt"
outputFile = open(filename,'w')
for counter in range (numberOfRandoms):
randomNumber = random.randint(1,500)
outputFile.write(str(randomNumber) + '\n')
outputFile.close()
print("Your numbers have been written and saved")
main()