##This is a program that I wrote and ran on my machine by python Can you find my
ID: 3591165 • Letter: #
Question
##This is a program that I wrote and ran on my machine by python
Can you find my input?
///////////////////////
import random
import sys
import markmod
arg1 = int(sys.argv[1])
if arg1 >0 and arg1 <= 1000:
print("Valid seed")
random.seed(arg1)
for x in range(10000):
y = random.random()
if markmod.printForValidNumber(x):
print(y)
print(random.random())
print(random.random())
print(random.random())
print(random.random())
break
##It printed the following:
#Valid seed
#0.6963297431051183
#0.1507136865403378
#0.015356268114414817
#0.6351698482848419
#0.1710703154580019
## result goes here:
Explanation / Answer
///////////////////////
import random
import sys
import markmod
arg1 = int(sys.argv[1])
if arg1 >0 and arg1 <= 1000:
print("Valid seed")
random.seed(arg1)
for x in range(10000):
y = random.random()
if markmod.printForValidNumber(x):
print(y)
print(random.random())
print(random.random())
print(random.random())
print(random.random())
break
Command line input has been highlighted with BOLD TEXT
sys.argv containes the arguments provided through command line.
len(sys.argv) will return number of arguments passed to python scripts.
sys.argv[0] is always the name of the python script which you are running.
you passed one argument to this script and it is stored in sys.argv[1]. then you converted it to INT data type.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.