Computer Science
Consider the code given below:
import random
r = random.randrange(100, 999, 5)
print(r, end = ' ')
r = random.randrange(100, 999, 5)
print(r, end = ' ')
r = random.randrange(100, 999, 5)
print(r)
Which of the following are the possible outcomes of the above code ? Also, what can be the maximum and minimum number generated by line 2 ?
(a) 655, 705, 220
(b) 380, 382, 505
(c) 100, 500, 999
(d) 345, 650, 110
Python Data Handling
18 Likes
Answer
The possible outcomes of the above code can be:
Option (a) — 655, 705, 220
Option (d) — 345, 650, 110
Maximum number can be 995 and minimum number can be 100.
Answered By
8 Likes
Related Questions
Consider the code given below:
import random r = random.randint(10, 100) - 10 print(r, end = ' ') r = random.randint(10, 100) - 10 print(r, end = ' ') r = random.randint(10, 100) - 10 print(r)
Which of the following are the possible outcomes of the above code? Also, what can be the maximum and minimum number generated by line 2?
(a) 12 45 22
(b) 100 80 84
(c) 101 12 43
(d) 100 12 10Consider the code given below:
import random r = random.random() * 10 print(r, end = ' ') r = random. random() * 10 print(r, end = ' ') r = random.random() * 10 print(r)
Which of the following are the possible outcomes of the above code? Also, what can be the maximum and minimum number generated by line 2 ?
(a) 0.5 1.6 9.8
(b) 10.0 1.0 0.0
(c) 0.0 5.6 8.7
(d) 0.0 7.9 10.0What will be the output produced?
w, x, y, z = True , 4, -6, 2 result = -(x + z) < y or x ** z < 10 print(result)
Program is giving a weird result of "0.50.50.50.50.50.50……….". Correct it so that it produces the correct result which is the probability value (input as 0.5) times 150.
probability = input("Type a number between 0 and 1: ") print("Out of 150 tries, the odds are that only", (probability * 150), "will succeed.")
[Hint. Consider its datatype.]