CBSE Class 11 Computer Science
Question 144 of 173
Data Handling — Question 33
Back to all questions 33
Question Question 20
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.]
Answer
The corrected program is below:
probability = float(input("Type a number between 0 and 1: "))
print("Out of 150 tries, the odds are that only", (probability * 150), "will succeed.")