# How to take input from user?

Since I'm new to Mathematica I want to have a Notebook which takes inputs from user and returns average of the inputs entered and plots it on x-y coordinate. How can I do this?

-
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign – ssch Nov 13 '12 at 16:50

## 2 Answers

This might be an example:

x = Input["Insert x coordinates (put them between {} brackets)",{}];
y = Input["Insert y coordinates (put them between {} brackets)",{}];
Mean[x]
Mean[y]
ListPlot[Transpose[{x, y}]]

-
Also check out tutorial/RequestingInput and tutorial/TextualInputAndOutputOverview in the Documentation Center (You can access it from the help menu, and I highly recommend the broadcasts on wolfram.com/broadcast/video.php?channel=86 to get you comfortable with mathematica) – ssch Nov 13 '12 at 16:41
Thanks. I will try it out. Actually i never mention my real problem but if any problem occur i will revert to stackexchange.com. Also can you tell me the best tutuorial for starter as i have to solve a simple problem(complex for starter) and submit before Thursday. – Soum Nov 13 '12 at 17:30
@Soum You could start from here. The Documentation is also a good place to start, for instance, for plotting. And, this collection of resources is also useful. – VLC Nov 13 '12 at 17:46

The question says "take input from the user", but this suggest a paradigm more suitable to another programming language. If what you $really$ want is to give the user a way to enter the data and then obtain the required plot, it's more straightforward to just define a function:

meanPlot[x_List, y_List] :=
Module[{xbar = Mean[x], ybar = Mean[y]},
Print[{xbar, ybar}];
ListPlot[Transpose[{x, y}],
Epilog -> {PointSize[Large], Red, Point[{xbar, ybar}]}]
]


And then use this so:

meanPlot[{5, 2, 9, 4}, {2, -1, 8, 2}]


The definition of meanPlot does minimal argument-checking (just that each argument is a list). And there are neater ways to combine the printout of the two means with the plot, e.g., use a Column construct or label the point of means with its coordinates.

-