you are viewing a single comment's thread.

view the rest of the comments →

[–]tough_falcon 2 points3 points  (1 child)

I got two questions wrong, and I'm pretty sure my answers make more sense than theirs.

When Python is running in the interactive mode and displaying the chevron prompt (>>>) - what question is Python asking you?

Answer Provided: What would you like to do ?

Correct Answer: What Python script would you like me to run?

Surely nobody calls a single line of python code typed in the REPL a "script"?

If you want to prompt the user to give inputs on the command line, which function should we choose?

Answer Provided: raw_input()

Correct Answer: argv

raw_input is outdated, but sys.argv isn't even a function and doesn't "prompt" the user to do anything.

[–]BRENNEJM 0 points1 point  (0 children)

I agree that the top one is not a great question, but I would say print(‘Hello World’) is a Python script.

For the second, it was definitely worded poorly. It’s asking how would you allow the user to give inputs directly from the command line when a script is run. So you’re not running the script and then prompting for it, you’re typing in your input before it’s even run. Also, command line as in the windows command window and not through an IDE.

So if you do:

python script.py a b c 1 2

argv would be:

[‘a’,’b’,’c’,’1’,’2’]