Computer Science, asked by Kshitizzz, 11 months ago

What does the function random.randrange(49,150) return in Python?

Answers

Answered by ankurbadani84
1

Answer:

It returns random number from 49 to 149 both inclusive.

Explanation:

Syntax of randrange is randrange (start, stop, step).

Start - Start Range of Random Number

Stop - Stop limit of Random Number. This number will never be generated by function.

Step - Step size. If set to say 10, number generated will be multiple of 10. If not specified this will be defaulted to 1.

random.randrange(49,150)  will returns random number from 49 to 149 both inclusive. Step will get set to 1.

Answered by poojan
7

It returns a random number between 49 and 149 (both inclusive).

Explanation:

randrange(startvalue, stopvalue) returns values between start and stop values, where start value is inclusive and stop value is excluded. So, the function returns a value between the start value and stop value - 1 inclusively.

However, If you want to include the stopvalue too, you can use another random function named 'ran dint()'

 

  • randrange is a python's inbuilt function in the class random. It returns a random value from the given range.

  • To access this function, first, we need to import 'random' module.

  • randrange function takes three parameters start value, stop value, point range (Optional; by default : 1), in the same order.

import random

random.randrange(startvalue(inclusive), stopvalue(excluded), rangingvalue(optional))

Learn more :

 

1) Write a python program to generate random no.​

brainly.in/question/15069095

2) How to generate random numbers in Python ?

brainly.in/question/16087795

3) Similar question.

https://brainly.in/question/8338419

Similar questions