Syntax # list.pop(pos) Parameter Values # | Parameter | Description | | pos | Optional. An int specifying index of item to be removed |
If no pos parameter is passed defaults to removing the last item in the list aka -1.
Example # fruits = ['apple', 'banana', 'cherry'] fruits.pop(1) print(fruits) ['apple', 'cherry']
Languages # Bash Python Lisp Clojure JavaScript Lua Paradigms # Imperative Functional Syntax # Code Linting Machine Learning # Physics-based Deep Learning Misc. # Art of problem solving: Hammock Driven Development 20220623214742-cool-dev-shit The real cost of context switching
PyInputPlus is a Python module that provides input validation.
Install # pip install --user pyinputplus Usage # i>>> import pyinputplus as pyip i>>> response = pyip.inputNum() five 'five' is not a number. 42 i>>> response 42 i>>> response = input('Enter a number: ') iEnter a number: 42 i>>> response '42' i>>> response = pyip.inputInt(prompt='Enter a number: ') Enter a number: cat 'cat' is not an integer. Enter a number: 42 i>>> response 42 Note, you can provide a prompt just like with input() by passing a prompt keyword argument to the PyInputPlus function.
...
Allows copying to and pasting from the system clipboard.
copy() paste()
Python # Virtual Environments # https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/ Notes # Python Notes Food Log Program Resources # Curated list of awesome python frameworks, libraries, software and resources
Awesome Python Handy modules # ConfigObj Recommended by Andy V. Handy for using config files (*.ini) files with Python Learning # 70+ Python Projects for Beginners, Intermediate & Advanced Developers Cheat Sheets # Python Cheat Sheet Books # Automate the Boring Stuff Learn Python the Hard Way Python Crash Course by Eric Matthes Recommended by David (has root) Biniek Think Python Introducing Python Video Series # Learn Python with Socratica Recommended by Noah A.
...
Python Notes # Basics # Math Operators Common Data Types String Concatenation and Replication Variables Common Functions Text and Number Equivalence Flow Control # Boolean Values Comparison Operators Boolean Operators Elements of Flow Control # Conditions Code Blocks Program Execution Flow Control Statements # if else elif while loops break continue for loops Importing Modules # Built-in Functions Standard Library Importing Modules Ending Programs Early # sys.
...
A Python module in the standard library that allows you to apply randomness to things.
Random numbers # random.int() ? Random lists # random.choice() random.shuffle() >>> import random >>> pets = ['Dog', 'Cat', 'Moose'] >>> random.choice(pets) 'Moose' >>> random.choice(pets) 'Cat' >>> import random >>> people = ['Alice', 'Bob', 'Carol', 'David'] >>> random.shuffle(people) >>> people ['Carol', 'Alice', 'David', 'Bob'] >>> random.shuffle(people) >>> people ['Bob', 'Carol', 'David', 'Alice'] Shuffle real smooth…
range()
Accepts up to 3 integer arguments.
First two arguments define the range while the 3rd argument defines the step interval.
Integers can be both positve and negative.
Examples # >>> for i in range(12, 16): ... print(i) ... 12 13 14 15 >>> for i in range(0, 10, 2): ... print(i) ... 0 2 4 6 8 A negative step-interval counts backwards.
>>> for i in range(5, -1, -1): .
...
A raw string completely ignores all escape characters and prints any backslash that appears in the string.
>>> print(r'That is Carol\'s cat.') That is Carol\'s cat. Note, this is useful for printing Windows file paths of the form C:\file\path\