- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

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

# Program to find probability of getting assigned seat for the last person in an airplane after seat shuffling in Python

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%"

## Example

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))

## Input

5

## Output

50%

- Related Articles
- 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
- Why are car seat-belts designed to stretch somewhat in a collision?
- Getting error not assigned on running SAP ABAP program
- Program to find last digit of the given sequence for given n in Python
- Python program to find probability of getting letter 'a' in some letters and k sized combinations
- A dice is thrown. Find the probability of getting an even number.
- A die is thrown. Find the probability of getting an even prime number.
- A die is thrown once. Find the probability of getting an odd number.
- When a dice is thrown once, find the probability of getting an even number.
- Program to find maximum number of groups getting fresh donuts in Python
- C# program to find the last matching element in an array
- C++ Program to Implement Fisher-Yates Algorithm for Array Shuffling
- In a simultaneous throw of a pair of dice, find the probability of getting an even number on first.

Advertisements