###
What's the probability of forming a triangle by breaking a stick twice?

Questions: Supposed that you have 2 chances to break a stick with length of 1 into 3 pieces. What is the probability that the 3 pieces form a triangle?

Code in Python:
[in:]

n=100
y>0
z>0
success = 0
fail = 0
n=1500

**for** i in **range**(0,1500):
x = rd.random()
y = rd.random()
**if** (y>0.5 and x<0.5 and y-x<0.5) or (x>0.5 and y<0.5 and x-y<0.5):
success = success+1
**else**:
fail = fail+1

probability = success/n
**print**(probability)

[out:]
0.24

Could you please provide information as to some of the numbers you used in your code?

ReplyDeleteHi. The number used in my code is exactly like above.

DeleteThankyou so much for sharing this analysis. I first got confused with some numbers but then when i went through it again i was able to figure it out. You are a genious. I wish ill be able to analyze data the same way some day

ReplyDeletepythyon training in bangalore

ReplyDeleteaws training in bangalore

artificial intelligence training in bangalore

blockchain training in bangalore

data science training in bangalore

machine learning training in bangalore

hadoop training in bangalore

iot training in bangalore

devops training in bangalore

uipath training in bangalore

Thank you for sharing this type of interview questions

ReplyDeleteIot Online Training

Iot Training in Bangalore

Itil Interview Questions

Salesforce Interview Questions

Msbi Interview questions

Salesforce Interview Questions

C Interview Questions