15 Useful Python One-Liners for Everyone

Must know for every Python programmer

Swathi Arun
Python in Plain English
3 min readMar 1, 2022

--

Photo by Emile Perron on Unsplash

1. Simulate coin toss:

Simulation of the coin toss can be done with one line of Python code. Using the random module, you can choose between head and tail choices.

import random
print(random.choice(['Head','Tail']))

2. Reverse like a Pro:

--

--

2x Top Writer || Power BI || Python || Art || Travel || Engineer || Writer|| Become a Medium Member by Clicking here: https://swathiarun63.medium.com/membership