READING-NOTE

View on GitHub

Game_of_Greed

ow to use the Random Module in Python?

When to use it? 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.

The Random module contains some very useful functions.

If we wanted a random integer, we can use the randint function Randint accepts two parameters: a lowest and a highest number. Generate integers between 1,5. The first value should be less than the second.

import random
print random.randint(0, 5)

#This will output either 1, 2, 3, 4 or 5.

If you want a larger number, you can multiply it.

For example, a random number between 0 and 100:

import random
random.random() * 100

Generate a random value from the sequence sequence.

random.choice( [‘red’, ‘black’, ‘green’] ). The choice function can often be used for choosing a random element from a list.

import random

myList = [2, 109, False, 10, "Lorem", 482, "Ipsum"]

random.choice(myList)

The shuffle function, shuffles the elements in list in place, so they are in a random order.

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

Generate a randomly selected element from range(start, stop, step) random.randrange(start, stop[, step])

import random

for i in range(3):
    print random.randrange(0, 101, 5)

Why use Risk Analysis?

Use of new hardware

Use of new technology

Use of new automation tool

The sequence of code

Availability of test resources for the application

  1. The time that you allocated for testing
  2. A defect leakage due to the complexity or size of the application
  3. Urgency from the clients to deliver the project
  4. Incomplete requirements

Risk Assessment

Moving on! Our next topic on Risk Analysis in Software Testing