Published in Python in Plain English·PinnedMember-only22 Things I Never Knew About Python Until Recently (Compilation)# Despite working with Python since 2017 1) Infinity values in Python a = float("inf") b = float("-inf") We can define infinity values in Python (above). Positive infinity is larger than all numbers, while negative infinity is smaller than all numbers. 2) Using ‘pprint’ to print stuff nicely We can use pprint to nicely print out complicated data structures without having to…Python7 min readPython7 min read
Published in Python in Plain English·PinnedMember-only7 Things I Never Knew About Python Until RecentlyI’ve been programming in Python for 5 years (since 2017) and only knew about these facts only quite recently. — I’ve been programming in Python for 5 years (since 2017) and only knew about the following facts only quite recently — here we go: 1) Private Variables In Classes Are Not Really Private class Dog(): def __init__(self, name): self.__name = name @property def name(self): return self.__namePython4 min readPython4 min read
PinnedMember-only5 Python Questions 75% Of You Probably Can’t Solve In One Line Of CodeBeing able to write code in one line probably won’t guarantee you a high-paying tech job, but it sure does feel satisfying. Here are thus 5 Python questions that can usually be easily solved under normal circumstances. The catch — you need to solve it in one line of code. 1. Checking If A Number Is Prime …Python4 min readPython4 min read
Published in Python in Plain English·PinnedMember-onlyHow Using ‘yield’ Instead of ‘return’ Can Make Your Python Code FasterA quick demonstration of why sometimes using yield is better and can make your code run faster (especially when dealing with lots of data). — When we started learning Python, we were probably taught to use the return keyword in functions rather than yield. In this article, I’ll quickly demonstrate why sometimes using yield is better and can make your code run faster (especially when dealing with lots of data).Python4 min readPython4 min read
Published in Python in Plain English·PinnedMember-only4 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 readPython4 min read
10 hours agoMember-onlyPython Word2Vec For Text Classification (With LSTM)# Plug & Play Code For Those With No Time — Installing Python Dependencies Paste this into your command prompt or terminal, and hit Enter. pip install numpy pandas scikit-learn tensorflow gensim Load Your Text Classification Dataset Whether it’s from a url, a CSV file or some other dataset. Then split it into x (the text) and y (the target variables).Python5 min readPython5 min read
Published in Python in Plain English·2 days agoMember-onlyUsing Python PyShark To Check For Incoming/Outgoing Packets# From A Certain IP — The Scenario Let’s say you want to monitor ALL outgoing and incoming UDP packets only from a certain known IP address. And you want to print out every single packet using Python. Installing PyShark PyShark is a Python wrapper for Tshark. Tshark is a command line version of Wireshark, which allows us to capture…Python2 min readPython2 min read
Published in Python in Plain English·Jan 27Member-onlyPython Environment Variables Explained In 3 MinutesDefinition Of Environment Variables Variables that are initialized outside of our Python program These environment variables can affect the behaviour of or Python program. A Very Simple Example Let’s say we have an environment variable env. if env == 'dev', our program is in development mode. if env == 'uat’, our program is in UAT mode. if env…Python3 min readPython3 min read
Published in Python in Plain English·Jan 24Member-onlyAnswers — 20 Python Recursion Practice QuestionsPart 5: Checking If Maze Is Solvable — Original Article: 20 Python Recursion Practice Questions # 10 Manageable Questions + 10 Less Manageable Questionspython.plainenglish.io 14) Checking if maze is solvable You are given a list of strings representing a maze. maze = [ 'S----', '##---', '---##', '----X' ] S means starting point — where the player starts from X means reward — the objective of the mazePython3 min readPython3 min read
Published in Python in Plain English·Jan 16Member-onlyI Found A Way To Change My Dog’s Gender# In Python — Link to previous article: https://python.plainenglish.io/can-anyone-successfully-change-my-dogs-gender-956e3a9f9cc4 So previously, I wrote a Dog class that prevented users from modifying its attributes from outside of the class. Or so I thought. class Dog: def __init__(self, name, gender): super().__setattr__('_Dog__name', name)…Python2 min readPython2 min read