- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Suppose we have an integer n, that is representing the number of seats in an airplane. Now consider the first passenger has lost his ticket, so he picks a random seat. Now everyone else has their ticket but if their seat is already taken, they will also select an available seat randomly. We have to find the probability that the last person gets their assigned seat.

So, if the input is like n = 5, then the output will be 0.5, the answer is always constant when there is more than one person, because either they have got the correct seat or not, so probability is always 50%, but for n = 1, it will be 100%

To solve this, we will follow these steps −

- return "50%" if n > 1 otherwise "100%"

Let us see the following implementation to get better understanding −

def solve(n): return "50%" if n > 1 else "100%" n = 5 print(solve(n))

5

50%

- Related Questions & Answers
- Airplane Seat Assignment Probability in C++
- Program to implement seat reservation manager in Python
- Program to check whether all can get a seat or not in Python
- Python program to find probability of getting letter 'a' in some letters and k sized combinations
- Program to Find Out the Probability of Having n or Fewer Points in Python
- Getting error not assigned on running SAP ABAP program
- Program to find path with maximum probability using Python
- C# program to find the last matching element in an array
- Find the probability of reaching all points after N moves from point N in C++
- Program to find maximum number of groups getting fresh donuts in Python
- Getting the last 30 rows in MySQL
- Program to find number of possible position in n-person line with few person at front and back in Python
- Program to find final states of rockets after collision in python
- Probability of getting more value in third dice throw in C++
- Program to find the K-th last node of a linked list in Python

Advertisements