On 10/15/2012 09:55 AM, Debashish Saha wrote: > how to insert random error in a programming?
I don't see how this phrase makes any sense without a lot more context. If I add the words "I'd like to know" in front of the phrase, and "session." at the end (and add the word "a" as appropriate), the best answer I'd come up with is to deprive the programmer of a lot of sleep the night before. If I just take the words in the phrase, and try to dream up the possible ways they could be meant... For example, perhaps you have a series of data, taken from some experiment, and you want to "break" the data, to make it appear more random (to fit the model less well). You might just want to iterate over the sample twice, once to calculate the average, min, and max. Then you might add to each sample a random signed value with a distribution based on those three values. Or you might be a teacher with a "perfect program," and you want to (programmatically) change it slightly, and see how long it takes your students to find the introduced error. This seems to me to be an extremely hard problem in the general case, though pretty easy for a human. Problem is that most random text changes will presumably cause compile errors, or "not defined". And those are trivial to find and fix for an experienced programmer, though first year students might need the practice. Or you might be trying to get your module to simulate various errors, randomly chosen. In which case, see Chris's or jean-Michel's response. Or you might be trying to cause other applications to crash, because you're pretending to be a virus. Or a dozen other things. You get the random module by import random. But beyond that, we'd have to understand your use case. Start by mentioning Python version and OS. Then give a brief summary of your level of experience in Python and in other langugages. Then list the description on the homework assignment. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list