Published in Python in Plain English·Pinned5 Tricks to Condense Your Code into One Line in PythonThese tricks can allow you to write many functions in just one line. — If you want to write your Python functions in one line, here are 5 tips and tricks that you can use in your code. …Python4 min read
Published in Towards Dev·Pinned4 Ways To Annoy Your Colleagues With Your Python CodeHere are 4 ways to write your code that will make your software engineer colleagues go “what the hell?” and give them a massive headache. 1) Using Weird Magic Methods Let’s say we need to add a and b together. The normal way x = a + b The annoying way x = a.__add__(b) This does the exact same thing as…Python5 min read
Published in CodeX·PinnedChecking If Maze Is Solvable In One Line Of PythonLet’s say we’re given a list of strings representing a maze: maze = [ "P---#", "###--", "----#", "-###-", "----X" ] P represents the player, and always starts at the top left X represents the reward, and is always at the bottom right - represents a path, which the player can…Python6 min read
Published in CodeX·PinnedAnother Python Question That Took Me Days To Solve As A BeginnerI started learning Python programming in university in 2017, and have come across a couple of weird practice questions that took me days to solve. One such question: A Python Question That Took Me Days To Solve When I Just Started 4 years ago in mid 2017, I took my first basic Python class in University. This class titled introduction to…medium.com Here, I’ll share another question that literally took me days to solve — well, it came up during a Python test and…Python5 min read
Pinnedif __name__ == “__main__” in Python Explained SimplyIf you just started learning Python, you’ve probably come across something like this: # stuff if __name__ == "__main__": # do stuff This article will attempt to explain as simply as possible what is happening here, and the situations where if __name__ == "__main__" is required. …Python4 min read
Published in Python in Plain English·3 days ago10 List Comprehension Exercises for BeginnersList comprehension exercises for you to level up your list comprehension game. — Maybe you’ve learnt about list comprehension in Python recently, but might not be that great at it yet. Here are 10 list comprehension practices (ordered from easy to difficult) for you to level up your list comprehension game. Answers are provided at the end of the article. Practices 1. Strings to Integers You are given…Python5 min read
6 days agoHow To Send Excel Files With Python Telegram Bot (Or Any Other Binary File)I spent way more time googling for the solution and trying to figure this out than I would have liked, so hopefully this saves you the frustration of doing so if you happen to be attempting the same thing. Installing The Relevant Library pip install python-telegram-bot Replace pip with pip3 if you’re using MacOS Some Basic Python Telegram Bot Code …Python3 min read
Published in Python in Plain English·May 164 Hard Python Questions That Will Probably Take You Days to SolveDifficult questions for Python beginners. — Here are 4 questions that actually took me multiple days to solve when I was still building up my foundations in Python. Do give them a go! 1. Largest Puddle You are given a 2D list of integers. map = [ [5, 5, 5, 5, 5, 2, 2]…Python4 min read
Published in Python in Plain English·May 14How to Install Python Libraries for BeginnersA beginners’ guide on installing Python libraries. — This can be intimidating if you’ve not done this before, but I promise that installing 3rd party libraries in Python is much easier than you think it is. Introduction To Pip Pip stands for Pip Installs Packages, and we mainly use it to install 3rd party Python libraries on our computers. Open Command Prompt (Windows) or Terminal (macOS) Windows Users:Python3 min read
Published in Python in Plain English·May 10How to Rank All Your Medium Stories by Views Using PythonRank all your Medium articles by views/reads in order to analyze the similarities between well-performing articles — So I was trying to rank all my Medium articles by views/reads in order to analyze the similarities between well-performing articles — I then realised that I had no easy way to rank them (stories stats) without an obnoxious amount of scrolling. …Python6 min read