Reading-Notes


Project maintained by eslamakram Hosted on GitHub Pages — Theme by mattgraham

How to use the Random Module in Python

The random module provides access to functions that support many operations. Perhaps the most important thing is that it allows you to generate random numbers.

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

Randint 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.

You are here: Home / Random / How to use the Random Module in Python How to use the Random Module in Python Author: PFB Staff Writer Last Updated: August 27, 2020

Overview In this post, I would like to describe the usage of the random module in Python. The random module provides access to functions that support many operations. Perhaps the most important thing is that it allows you to generate random numbers.

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.

Random functions: The Random module contains some very useful functions.

Randint 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.

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

 For example, a random number between 0 and 100:
  import random
  random.random() * 100

Choice Generate a random value from the sequence sequence. random.choice( [‘red’, ‘black’, ‘green’] ).

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

What is Risk Analysis in Software Testing and how to perform it?

In Software Testing, risk analysis is the process of identifying the risks in applications or software that you built and prioritizing them to test. After that, the process of assigning the level of risk is done. The categorization of the risks takes place, hence, the impact of the risk is calculated.

Why use Risk Analysis? In any software, using risk analysis at the beginning of a project highlights the potential problem areas. After knowing about the risk areas, it helps the developers and managers to mitigate the risks. When a test plan has been created, risks involved in testing the product are to be taken into consideration along with the possibility of the damage they may cause to your software along with solutions.

How to perform Risk Analysis?

There are three steps:

  1. Searching the risk
  2. Analyzing the impact of each individual risk
  3. Measures for the risk identified