How to use the Random Module in Python
We want the computer to pick a random number in a given range Pick a random element from a list, pick a random card from a deck, flip a coin etc. When making your password database more secure or powering a random page feature of your website
Random functions
- Randint
import random
print random.randint(0, 5)
This will output either 1, 2, 3, 4 or 5.
- Random
For example, a random number between 0 and 100:
import random
random.random() * 100
- Choice
import random
myList = [2, 109, False, 10, "Lorem", 482, "Ipsum"]
random.choice(myList)
- Shuffle
from random import shuffle
x = [[i] for i in range(10)]
shuffle(x)
Output:
# print x gives [[9], [2], [7], [0], [4], [5], [3], [1], [8], [6]]
# of course your results will vary
- Randrange
import random
for i in range(3):
print random.randrange(0, 101, 5)
What is Risk Analysis in Software Testing and how to perform it?
Software Risks: You should be well versed with the risks associated with the software development process.
Risk Assessment
In the risk analysis process, these steps prove to be the most important one. It is said that this step is way too complex and should be tackled with the utmost care. After risk identification, assessment has to be dealt programmatically.
How to perform Risk Analysis?
-
Searching the risk
-
Analyzing the impact of each individual risk
-
Measures for the risk identified
TestCoverage
Some people think that you have too many tests if they take too long to run. I’m less convinced by this argument. You can always move slow tests to a later stage in your deployment pipeline, or even pull them out of the pipeline and run them periodically. Doing these things will slow down the feedback from those tests, but that’s part of the trade-off of build times versus test confidence
Big O Notation
Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann, Edmund Landau, and others, collectively called Bachmann–Landau notation or asymptotic notation.