Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Selecting Parameters for the Simulation

00:00 While you can hard-code the parameters for the simulation, wouldn’t it be easier to let the user do that at runtime? Maybe the manager would like to do a what-if using your model to see if it’s worthwhile to hire an additional usher, or, if someone calls in sick, to see if moving an employee from the cashier station to concessions would cause a large impact on wait times.

00:21 So to do this, go ahead and define a new function called get_user_input(), and then ask the user how many cashiers—which will be "Input # of cashiers working: ".

00:37 The num_servers is going to be input("Input # of servers working: "). And then the num_ushers, which will be input("Input # of ushers working: ").

00:58 Okay! Then you can say params is just going to be a list of this, so [num_users, num_servers, num_ushers], And then if all(), and then say the string of each is a digit for i in params.

01:21 And this is just to check that the inputs are valid integers. You can then say params is going to be a list comprehension of the integer of each, because input() is going to return a string.

01:37 Otherwise, go ahead and print a little error message, something like "Could not parse input. The simulation will use default values".

01:53 And then these default values—so do a newline ("\n") and they’re going to be "1 cashier, 1 server, 1 usher." And then set params = [1, 1, 1].

02:09 And once this is all completed, go ahead and return those parameters. And that’s all there is to it! A few lines of code in a relatively straightforward function makes the entire script much easier to work with later on.

Become a Member to join the conversation.