Start Making Progress On Coding Projects With Programming Basic Cheat Sheet

There are so many programming languages, it can be hard to know which to focus on. As a beginner, it’s easy to be overwhelmed with the possibilities. Even seasoned coders are constantly learning.

Start Making Progress On Coding Projects With Programming Basic Cheat Sheet
Start Making Progress On Coding Projects With Programming Basic Cheat Sheet

Whether you’re using CSS3, Python, or SQL, we’ve put together this article to teaches you everything you need to know to get going with programming and take your current skills up a level. This article contains:

  • Arduino Commands
  • CSS3 Properties
  • HTML Essentials
  • Javascript Commands
  • Python RegEx Shortcuts
  • Raspberry Pi Commands
  • SQL Commands
  • Visual Studio Code Shortcuts

This article is everything you need to grasp the programming basics and to start making progress on your coding projects.

Table of contents

Arduino Commands
CSS3 Properties
HTML Essentials
Javascript Commands
Python RegEx Shortcuts
Raspberry Pi Commands
SQL Commands
Visual Studio Code Shortcuts

Arduino Commands

VerifyScans your code and reports any errors
UploadCompiles your code and uploads it to the Arduino board via USB
NewOpens a blank Arduino sketch
OpenOpens a list of your saved sketches in the file browser
SaveSaves your current sketch
Serial MonitorOpens the serial monitor in a new window
Arduino Commands for Arduino IDE Toolbar
void setup {}Runs once at startup
void loop {}Runs continually
Arduino Commands for Arduino Program Structure
pinMode(PIN_NUMBER, INPUT/OUTPUT)Sets the pin at the location PIN_NUMBER to be either an INPUT or an OUTPUT
pinMode(PIN_NUMBER, INPUT_PULLUP)Sets the pin at the location PIN_NUMBER to be an input using the Arduino board’s built-in pull-up resistor
digitalRead(PIN_NUMBER)Reads the input at PIN_NUMBER and returns a 1 or 0 (HIGH or LOW)
digitalWrite(PIN_NUMBER, VALUE)Writes a value of 1 or 0 (HIGH or LOW) to digital pin PIN_NUMBER
analogRead(PIN_NUMBER)Reads the analog pin PIN_NUMBER and returns an integer between 0 and 1023
analogWrite(PIN_NUMBER, VALUE)Emulates analog output VALUE using PWM on PIN_NUMBER (note: only available on pins 3, 5, 6, 9, 10, and 11)
analogReference(DEFAULT)Use the default reference voltage (5V or 3.3V depending on board voltage)
analogReference(INTERNAL)Use an internal reference voltage (1.1v for ATmega168/328p, 2.56 for ATmega 32U4/8)
analogReference(EXTERNAL)Use a voltage applied to the AREF pin as voltage reference (note: 0-5V only)
Built in Arduino Functions for Pin setup
millis()Returns the time in milliseconds since the Arduino sketch began running as an unsigned long integer
micros()Returns the time in microseconds since the Arduino sketch began running as an unsigned long integer
delay(INTEGER)Delays program execution for INTEGER milliseconds
delayMicroseconds(INTEGER)Delays program execution for INTEGER microseconds
Built in Arduino Functions for Time functions
min(i, j)Returns the lowest of the two values i and j
max(i,j)Returns the highest of the two values i and j
abs(i)Returns the absolute value of i
sin(angle)Returns the sine of an angle in radians
cos(angle)Returns the cosine of an angle in radians
tan(angle)Returns the tangent of an angle in radians
sqrt(i)Returns the square root of i
pow(base, exponent)Raises the number base to the number exponent (e.g pow (2 , 3) ==8)
constrain(i, minval, maxval)Contrains the value i between minval and maxval
map(val, fromL, fromH, toL, toH)Remaps val from one range to another
random(i)Returns a random long integer smaller than i
random(i, j)Returns a random long integer between i and j
randomSeed(k)Uses the value k to seed the random() function
Built in Arduino Functions for Mathematical functions
(type)variableCasts the value of variable to a new type
Arduino Commands for Casting
Serial.begin(speed)Start serial communication at a specified speed
Serial.end()Close serial communication
Serial.print(DATA)Prints DATA to the serial port. DATA can be characters, strings, integers and floating point numbers
Serial.available()Return the number of characters available to read in the serial buffer
Serial.read()Read the first character in the serial buffer (returns -1 if no data is available)
Serial.write(DATA)Write DATA to the serial buffer. DATA can be a character, integer, or array
Serial.flush()Clears the serial buffer once outgoing communication is complete
Arduino Commands for Serial Communication
Servo myServoCreates the variable myServo of type Servo
myServo.attach(PIN_NUMBER)Associated myServo with the pin at location PIN_NUMBER
myServo.write(angle)Writes an angle between 0 and 180 to the servo atached to myServo
myServo.writeMicroseconds(uS)Writes a value in microseconds to the servo attached to myServo (typically between 1000 and 2000 with 1500 as the midpoint)
myServo.read()Returns an integer containing the current angle of the servo between 0 – 180
myServo.attached()Returns true if the servo is attached to a pin
myServo.detach()Dissasociates myServo with an attached pin
Arduino Commands for Servo (#include <Servo.h>)

CSS3 Properties

backgroundDefines a variety of background properties within one declaration.
background-attachmentSpecifies whether the background image is fixed or scrolls with the webpage.
background-colorDefines the background color of an element on the webpage.
background-imageDefines an element’s background image.
background-clipSpecifies how far the background images or color extends for an element.
background-originSpecifies the positioning area of the background images.
background-positionDefines the origin of a background image.
background-repeatSpecifies how the background image is tiled.
background-sizeSpecifies the size of the background images.
CSS3 Background Properties
borderSets the border width, style, and color for all four sides of an element.
border-bottomSets the width, style, and color for the bottom border of an element.
border-bottom-colorSets the color of the bottom border of an element.
border-bottom-left-radiusDefines the shape of the bottom-left border corner of an element.
border-bottom-right-radiusDefines the shape of the bottom-right border corner of an element.
border-bottom-styleSets the style of the bottom border of an element.
border-bottom-widthSets the width of the bottom border of an element.
border-colorSets the color of the border on all the four sides of an element.
border-imageSpecifies how an image is to be used in place of the border styles.
border-image-outsetSpecifies the amount by which the border image area extends beyond the border box.
border-image-repeatSpecifies whether the border image should be repeated, rounded or stretched.
border-image-sliceSpecifies the inward offsets of the image-border.
border-image-sourceSpecifies the location of the image to be used as a border.
border-image-widthSpecifies the width of the imageborder.
border-leftSets the width, style, and color of the left border of an element.
border-left-colorSets the color of the left border of an element.
border-left-styleSets the style of the left border of an element.
border-left-widthSets the width of the left border of an element.
border-radiusDefines the shape of the border corners of an element.
border-rightSets the width, style, and color of the right border of an element.
border-right-colorSets the color of the right border of an element.
border-right-styleSets the style of the right border of an element.
border-right-widthSets the width of the right border of an element.
border-styleSets the style of the border on all the four sides of an element.
border-topSets the width, style, and color of the top border of an element.
border-top-colorSets the color of the top border of an element.
border-top-left-radiusDefines the shape of the top-left border corner of an element.
border-top-right-radiusDefines the shape of the top-right border corner of an element.
border-top-styleSets the style of the top border of an element.
border-top-widthSets the width of the top border of an element.
border-widthSets the width of the border on all the four sides of an element.
CSS3 Border Properties
heightDefines the height of an element.
max-heightDefines the maximum height of an element.
max-widthDefines the maximum width of an element.
min-heightDefines the minimum height of an element.
min-widthDefines the minimum width of an element.
widthSpecify the width of an element.
CSS3 Dimension Properties
ContentInserts generated content.
quotesSpecifies quotation marks for embedded quotations.
counter-resetCreates or resets one or more counters.
counter-incrementIncrements one or more counter values.
CSS3 Generated Content Properties
align-contentSpecifies the alignment of flexible container’s items.
align-itemsSpecifies the default alignment for items.
align-selfSpecifies the alignment for selected items.
flexSpecifies the components of a flexible length.
flex-basisSpecifies the initial main size of the flex item.
flex-directionSpecifies the direction of the flexible items.
flex-flowA shorthand property for the flexdirection and the flex-wrap properties.
flex-growSpecifies how the flex item will grow relative to the other items inside the flex container.
flex-shrinkSpecifies how the flex item will shrink relative to the other items inside the flex container.
flex-wrapSpecifies whether the flexible items should wrap or not.
justify-contentSpecifies how flex items are aligned along the main axis of the flex container after any flexible lengths and auto margins have been resolved.
orderSpecifies the order in which a flex items are displayed and laid out within a flex container.
CSS3 Flexible Box Layout Properties
fontDefines a variety of font properties within one declaration like the font-style, font-variant, font-weight, font-size/line-height, and the font-family.
font-familyDefines a list of fonts for element.
font-sizeDefines the font size for the text.
font-size-adjustPreserves the readability of text when font fallback occurs.
font-stretchSelects a normal, condensed, or expanded face from a font.
font-styleDefines the font style for the text.
font-variantSpecify the font variant.
font-weightSpecify the font weight of the text.
CSS3 Font Properties
list-styleDefines the display style for a list and list elements.
list-style-imageSpecifies the image to be used as a list-item marker.
list-style-positionSpecifies the position of the list item marker.
list-style-typeSpecifies the marker style for a list-item.
CSS3 List Properties
marginSets the margin on all four sides of the element.
margin-bottomSets the bottom margin of the element.
margin-leftSets the left margin of the element.
margin-rightSets the right margin of the element.
margin-topSets the top margin of the element.
CSS3 Margin Properties
column-countSpecifies the number of columns in a multi-column element.
column-fillSpecifies how columns will be filled.
column-gapSpecifies the gap between the columns in a multi-column element.
column-ruleSpecifies a straight line, or “rule”, to be drawn between each column in a multi-column element.
column-rule-colorSpecifies the color of the rules drawn between columns in a multi-column layout.
column-rule-styleSpecifies the style of the rule drawn between the columns in a multi-column layout.
column-rule-widthSpecifies the width of the rule drawn between the columns in a multi-column layout.
column-spanSpecifies how many columns an element spans across in a multicolumn layout.
column-widthSpecifies the optimal width of the columns in a multi-column element.
columnsA shorthand property for setting column-width and column-count properties.
column-countSpecifies the number of columns in a multi-column element.
CSS3 Multi-Column Layout Properties
outlineSets the width, style, and color for all four sides of an element’s outline.
outline-colorSets the color of the outline.
outline-offsetSet the space between an outline and the border edge of an element.
outline-styleSets a style for an outline.
outline-widthSets the width of the outline.
CSS3 Outline Properties
paddingSets the padding on all four sides of the element.
padding-bottomSets the padding to the bottom side of an element.
padding-leftSets the padding to the left side of an element.
padding-rightSets the padding to the right side of an element.
padding-topSets the padding to the top side of an element.
CSS3 Padding Properties
page-break-afterInsert a page breaks after an element.
page-break-beforeInsert a page breaks before an element.
page-break-insideInsert a page breaks inside an element.
CSS3 Print Properties
border-collapseSpecifies whether table cell borders are connected or separated.
border-spacingSets the spacing between the borders of adjacent table cells.
caption-sideSpecify the position of table’s caption.
empty-cellsShow or hide borders and backgrounds of empty table cells.
table-layoutSpecifies a table layout algorithm.
border-collapseSpecifies whether table cell borders are connected or separated.
CSS3 Table Properties
directionDefine the text direction/writing direction.
tab-sizeSpecifies the length of the tab character.
text-alignSets the horizontal alignment of inline content.
text-align-lastSpecifies how the last line of a block or a line right before a forced line break is aligned when text-align is justify.
text-decorationSpecifies the decoration added to text.
text-decoration-colorSpecifies the color of the textdecoration- line.
text-decoration-lineSpecifies what kind of line decorations are added to the element.
text-decoration-styleSpecifies the style of the lines specified by the text-decoration-line property
text-indentIndent the first line of text.
text-justifySpecifies the justification method to use when the text-align property is set to justify.
text-overflowSpecifies how the text content will be displayed, when it overflows the block containers.
text-shadowApplies one or more shadows to the text content of an element.
text-transformTransforms the case of the text.
line-heightSets the height between lines of text.
vertical-alignSets the vertical positioning of an element relative to the current text baseline.
letter-spacingSets the extra spacing between letters.
word-spacingSets the spacing between words.
white-spaceSpecifies how white space inside the element is handled.
word-breakSpecifies how to break lines within words.
word-wrapSpecifies whether to break words when the content overflows the boundaries of its container.
CSS3 Text Properties
backface-visibilitySpecifies whether or not the “back” side of a transformed element is visible when facing the user.
perspectiveDefines the perspective from which all child elements of the object are viewed.
perspective-originDefines the origin (the vanishing point for the 3D space) for the perspective property.
transformApplies a 2D or 3D transformation to an element.
transform-originDefines the origin of transformation for an element.
transform-styleSpecifies how nested elements are rendered in 3D space.
CSS3 Transform Properties
transitionDefines the transition between two states of an element.
transition-delaySpecifies when the transition effect will start.
transition-durationSpecifies the number of seconds or milliseconds a transition effect should take to complete.
transition-propertySpecifies the names of the CSS properties to which a transition effect should be applied.
transition-timing-functionSpecifies the speed curve of the transition effect.
CSS3 Transition Properties
displaySpecifies how an element is displayed onscreen.
positionSpecifies how an element is positioned.
topSpecify the location of the top edge of the positioned element.
rightSpecify the location of the right edge of the positioned element.
bottomSpecify the location of the bottom edge of the positioned element.
leftSpecify the location of the left edge of the positioned element.
floatSpecifies whether or not a box should float.
clearSpecifies the placement of an element in relation to floating elements.
z-indexSpecifies a layering or stacking order for positioned elements.
overflowSpecifies the treatment of content that overflows the element’s box.
overflow-xSpecifies how to manage the content when it overflows the width of the element’s content area.
overflow-ySpecifies how to manage the content when it overflows the height of the element’s content area.
resizeSpecifies whether or not an element is resizable by the user.
clipDefines the clipping region.
visibilitySpecifies whether or not an element is visible.
cursorSpecify the type of cursor.
box-shadowApplies one or more drop-shadows to the element’s box.
box-sizingAlter the default CSS box model.
CSS3 Visual Formatting Properties
animationSpecifies the behavior of all animations.
animation-delaySpecifies when the animation will start with a delay.
animation-directionSpecifies whether the animation should play forward, backward, or in alternate cycles.
animation-durationSpecifies the number of seconds or milliseconds an animation should take to complete one cycle.
animation-fill-modeSpecifies how a CSS animation should apply styles to its target before and after it is executing.
animation-iteration-countSpecifies the number of times an animation cycle should be played before stopping.
animation-nameSpecifies the name of @keyframes defined animations that should be applied to the selected element.
animation-play-stateSpecifies whether the animation is running or paused.
animation-timing-functionSpecifies how a CSS animation should progress over the duration of each cycle.
CSS3 Animation Properties

HTML Essentials

<html>…</html>The first and last tag of an HTML document. All other tags lie between these opening and closing tags.
<head>…</head>Specifies the collection of metadata for the document.
<title>…</title>Describes the title for the page and shows up in the browser’s title bar.
<body>…</body>Includes all content that will be displayed on the webpage.
<base/>Mentions the base URL and all relative links to the document.
<meta/>For extra information about the page like author, publish date, etc.
<link/>Links to external elements like style sheets.
<style>…</style>Contains document style information like CSS (Cascading Style Sheets).
<script>…</script>Contains links to external scripts.
HTML code for Document Information
<strong>…</strong> OR <b>…</b>Makes text bold.
<em>…</em>Italicizes text and makes it bold.
<i>…</i>Italicizes text but does not make it bold.
<strike>…</strike>Strikethrough text.
<cite>…</cite>Cites an author of a quote.
<del>…</del>Labels a deleted portion of a text.
<ins>…</ins>Shows a section that has been inserted into the content.
<blockquote>…</blockquote>For displaying quotes. Often used with the <cite> tag.
<q>…</q>For shorter quotes.
<abbr>…</abbr>For abbreviations and full-forms.
<address>…</address>Specifies contact details.
<dfn>…</dfn>For definitions.
<code>…</code>For code snippets.
<sub>…</sub>For writing subscripts.
<sup>…</sup>For writing superscripts.
<small>…</small>For reducing the text size and marking redundant information in HTML5.
HTML code for Text Formatting
<h1…h6>…</h1…h6>Different levels of headings. H1 is the largest and H6 is the smallest.
<div>…</div>For dividing content into blocks.
<span>…</span>Includes inline elements, like an image, icon, emoticon, without ruining the formatting of the page.
<p>…</p>Contains plain text.
<br/>Creates a new line.
<hr/>Draws a horizontal bar to show end of the section.
HTML code for Document Structure
<ol>…</ol>For ordered list of items.
<ul>…</ul>For unordered list of items.
<li>…</li>For individual items in a list.
<dl>…</dl>List of items with definitions.
<dt>…</dt>The definition of a single term inline with body content.
<dd>…</dd>The description for the defined term.
HTML code for List
<a href=””>…</a>Anchor tag for hyperlinks.
<a href=”mailto:”>…</a>Tag for linking to email addresses.
<a href=”tel://###-###”>…</a>Anchor tag for listing contact numbers.
<a name=”name”>…</a>Anchor tag for linking to another part of the same page.
<a href=”#name”>…</a>Navigates to a div section of the webpage. (Variation of the above tag)
HTML code for Links
<img />For displaying image files.
Attribute for the <img> tag
src=”url”Link to the source path of the image.
alt=”text”The text displayed when a mouse is hovered over the image.
height=””Image height in pixels or percentages.
width=””Image width in pixels or percentages.
align=””Relative alignment of the image on the page.
border=””Border thickness of the image.
<map>…</map>Link to a clickable map.
<map name=””>…</map>Name of the map image.
<area />The image area of an image map.
Attribute for the <area> tag
shape=””Shape of the image area.
coords=””Coordinates of the map image area.
HTML code for Images
<form>…</form>The parent tag for an HTML form.
Attributes for the <form> tag
action=”url”The URL where form data is submitted.
method=””Specifies the form submission protocol (POST or GET).
enctype=””The data encoding scheme for POST submissions.
autocompleteSpecifies if form autocomplete is on or off.
novalidateSpecifies whether the form should be validated before submission.
accept-charsetsSpecifies character encoding for form submissions.
targetShows where the form submission response will be displayed.
<fieldset>…</fieldset>Groups related elements in the form/
<label>…</label>Specifies what the user should enter in each form field.
<legend>…</legend>A caption for the fieldset element.
<input />Specifies what type of input to take from the user.
Attributes for the <input> tag
type=””Determines the type of input (text, dates, password).
name=””Specifies the name of the input field.
value=””Specifies the value in the input field.
size=””Sets the number of characters for the input field.
maxlength=””Sets the limit of input characters allowed.
requiredMakes an input field compulsory.
width=””Sets width of the input field in pixels.
height=””Sets height of the input field in pixels.
placeholder=””Describes expected field value.
pattern=””Specifies a regular expression, which can be used to look for patterns in the user’s text.
min=””The minimum value allowed for an input element.
max=””The maximum value allowed for an input element.
disabledDisables the input element.
<textarea>…</textarea>For capturing longer strings of data from the user.
<select>…</select>Specifies a list of options which the user can choose from.
Attributes for the <select> tag
name=””Specifies name for a dropdown list.
size=””Number of options given to the user.
multipleSets whether the user can choose multiple options from the list.
requiredSpecifies whether choosing an option/s is necessary for form submission.
autofocusSpecifies that a drop-down list automatically comes into focus after a page loads.
<option>…</option>Defines items in a dropdown list.
value=””Displays the text for any given option.
selectedSets default option that is displayed.
<button>…</button>Tag for creating a button for form submission.
HTML code for Forms
<object>…</object>Describes the embedded filetype.
Attributes for the <object> tag
height=””The height of the object.
width=””The width of the object.
type=””The type of media the object contains.
<iframe>…</iframe>An inline frame for embedding external information.
name=””The name of the iFrame.
src=””The source URL for the content inside the frame.
srcdoc=””The HTML content within the frame.
height=””The height of the iFrame.
width=””The width of the iFrame.
<param />Adds extra parameters to customize the iFrame.
<embed>…</embed>Embeds external application or plugin.
Attributes for the <object> tag
height=””Sets the height of the embed.
width=””Sets the width of the embed.
type=””The type or format of the embed.
src=””The source path of the embedded file.
HTML code for Objects and iFrames
<table>…</table>Defines all content for a table.
<caption>…</caption>A description of the table.
<thead>…</thead>Headers for each column in the table.
<tbody>…</tbody>Defines the body data for the table.
<tfoot>…</tfoot>Describes the content for the table’s footer.
<tr>…</tr>Content for a single row.
<th>…</th>The data in a single header item.
<td>…</td>Content within a single table cell.
<colgroup>…</colgroup>Groups columns for formatting.
<col>A single column of information.
HTML code for Tables
<header>…</header>Specifies the webpage header.
<footer>…</footer>Specifies the webpage footer.
<main>…</main>Marks main content of the webpage.
<article>…</article>Specifies an article.
<aside>…</aside>Specifies sidebar content of a page.
<section>…</section>Specifies a particular section in the webpage.
<details>…</details>For describing extra information.
<summary>…</summary>Used as a heading for the above tag. Is always visible to the user.
<dialog>…</dialog>Creates a dialog box.
<figure>…</figure>Used for including charts and figures.
<figcaption>…</figcaption>Describes a <figure> element.
<mark>…</mark>Highlights a specific part of the text.
<nav>…</nav>Set of navigation links on a webpage.
<menuitem>…</menuitem>A particular item from a list or a menu.
<meter>…</meter>Measures data within a given range.
<progress>…</progress>Places a progress bar and tracks progress.
<rp>…</rp>Displays text that do not support Ruby annotations.
<rt>…</rt>Displays East Asia typography character details.
<ruby>…</ruby>A Ruby annotation for East Asian typography.
<time>…</time>Identifies time and date.
<wbr>A line break within the content.
HTML5 New Tags
&#34; &quot;Quotation Marks
&#60; &lt;Lesser than sign (<)
&#62; &gt;Greater than sign (>)
&#160; &nbsp;Non-breaking space
&#169; &copy;Copyright symbol
&#153; &ucirc;Trademark symbol
&#64; &Uuml;“at” symbol (@)
&#38; &amp;Ampersand symbol (&)
&#149; &ouml;Small bullet
HTML5 Character Objects

Javascript Commands

Concat()Join several arrays into one
copyWithin()Copy array elements within the array, to and from specified positions
idexOf()Return the primitive value of the specified object
includes()Check if an array contains the specified element
join()Combine elements of an array into a single string and return the string
entries()Return a key/value pair Array Iteration Object
every()Check if every element in an array passes a test
fill()Fill the elements in an array with a static value
filter()Create a new array with every element in an array that pass a test
find()Return the value of the first element in an array that pass a test
forEach()Call a function for each array element
from()Create an array from an object
lastIndexOf()Give the last position at which a given element appears in an array
pop()Remove the last element of an array
push()Add a new element at the end
reverse()Sort elements in descending order
reduce()Reduce the values of an array to a single value (going left-to-right)
reduceRight()Reduce the values of an array to a single value (going right-to-left)
shift()Remove the first element of an array
slice()Pull a copy of a portion of an array into a new array of 4 24
sort()Sort elements alphabetically
splice()Add elements in a specified way and position
unshift()Add a new element to the beginning
JavaScript Arrays Commands
toString()Convert a Boolean value to a string, and return the result
valueOf()Return the first position at which a given element appears in an array
toSource()Return a string representing the source code of the object
JavaScript Boolean Methods
+Addition
Subtraction
*Multiplication
/Division
(…)Grouping operator (operations within brackets are executed earlier than those outside)
%Modulus (remainder)
++Increment numbers
Decrement numbers
==Equal to
===Equal value and equal type
!=Not equal
!==Not equal value or not equal type
>Greater than
<Lesser than
>=Greater than or equal to
<=Lesser than or equal to
?Ternary operator
JavaScript Arithmetic Operators
&&Logical AND
||Logical OR
!Logical NOT
JavaScript Logical Operators
&AND statement
|OR statement
~NOT
^XOR
<<Left shift
>>Right shift
>>>Zero fill right shift
JavaScript Bitwise Operators
alert()Output data in an alert box in the browser window
confirm()Open up a yes/no dialog and return true/false depending on user click
console.log()Write information to the browser console (good for debugging purposes)
document.write()Write directly to the HTML document
prompt()Create a dialog for user input
JavaScript Functions
decodeURI()Decode a Uniform Resource Identifier (URI) created by encodeURI or similar
decodeURIComponent()Decode a URI component
encodeURI()Encode a URI into UTF-8
encodeURIComponent()Same but for URI components
eval()Evaluate JavaScript code represented as a string
isFinite()Determine whether a passed value is a finite number
isNaN()Determine whether a value is an illegal number
Number()Convert an object’s value to a number
parseFloat()Parse a string and return a floating point number
parseInt()Parse a string and return an integer
JavaScript Global Functions
forThe most common way to create a loop in JavaScript
whileSet up conditions under which a loop executes
do whileSimilar to the while loop, however, it executes at least once and performs a check at the end to see if the condition is met to execute again
breakStop and exit the cycle if certain conditions are mets
continueSkip parts of the cycle if certain conditions are met
JavaScript Loops
\’Single quote
\”Double quote
\\Backslash
\bBackspace
\fForm feed
\nNew line
\rCarriage return
\tHorizontal tabulator
\vVertical tabulator
JavaScript Escape Characters
charAt()Return a character at a specified position inside a string
charCodeAt()Give the unicode of character at that position
concat()Concatenate (join) two or more strings into one
fromCharCode()Return a string created from the specified sequence of UTF-16 code units
indexOf()Provide the position of the first occurrence of specified text within a string
lastIndexOf()Same as indexOf() but with the last occurrence, searching backwards
match()Retrieve the matches of a string against a search pattern
replace()Find and replace specified text in a string
search()Execute a search for a matching text and return its position
slice()Extract a section of a string and return it as a new string
split()Split a string object into an array of strings at a specified position
startsWith()Check whether a string begins with specified characters
substr()Similar to slice() but extracts a substring depended on a specified number of characters
substring()Similar to slice() but can’t accept negative indices
toLowerCase()Convert strings to lowercase
toUpperCase()Convert strings to uppercase
valueOf()Return the primitive value (that has no properties or methods) of a string object
JavaScript String Methods
eEvaluate replacement
iPerform case-insensitive matching
gPerform global matching
mPerform multiple line matching
sTreat strings as single line
xAllow comments and whitespace in pattern
UUngreedy pattern
JavaScript Regular Expression Syntax – Pattern Modifiers
[abc]Find any of the characters in the brackets
[^abc]Find any character not in the brackets
[0-9]Find digit specified in the brackets
[A-z]Find any character from uppercase A to lowercase z
(a|b|c)Find any of the alternatives separated with |
JavaScript Regular Expression Syntax – Brackets
.Find a single character, except newline or line terminator
\wWord character
\WNon-word character
\dA digit
\DA non-digit character
\sWhitespace character
\SNon-whitespace character
\bFind a match at the beginning/end of a word
\BFind a match not at the beginning/end of a word
\0NUL character
\nA new line character
\fForm feed character
\rCarriage return character
\tTab character
\vVertical tab character
\xxxCharacter specified by an octal number xxx
\xddLatin character specified by a hexadecimal number dd
\uddddUnicode character specified by a hexadecimal number dddd
JavaScript Regular Expression Syntax – Metacharacters
n+Match any string that contains at least one n
n*Any string that contains zero or more occurrences of n
n?Any string that contains zero or one occurrences of n
n{X}Any string that contains a sequence of X n’s
n{X,Y}Strings that contains a sequence of X to Y n’s
n{X,}Matches any string that contains a sequence of at least X n’s
n$Any string with n at the end of it
^nString with n at the beginning of it
?=nAny string that is followed by a specific string n
?!nString that is not followed by a specific string n
JavaScript Regular Expression Syntax – Quantifiers
MAX_VALUEMaximum numeric value representable in JavaScript
MIN_VALUESmallest positive numeric value representable in JavaScript
NaN“Not-a-Number” value
NEGATIVE_INFINITYNegative Infinity value
POSITIVE_INFINITYPositive Infinity value
JavaScript Regular Expression Syntax – Number Properties
toExponential()Return a string with a rounded number written as exponential notation
toFixed()Return string of a number with a specified number of decimals
toPrecision()Return string of a number written with a specified length
toString()Return a number as a string
valueOf()Return a number as a number
JavaScript Regular Expression Syntax – Number Methods
EEuler’s number
LN2Natural logarithm of 2
LN10Natural logarithm of 10
LOG2EBase 2 logarithm of E
LOG10EBase 10 logarithm of E
PIThe number PI
SQRT1_2Square root of 1/2
SQRT2Square root of 2
JavaScript Regular Expression Syntax – Math Properties
abs(x)Return the absolute (positive) value of x
acos(x)Arccosine of x, in radians
asin(x)Arcsine of x, in radians
atan(x)Arctangent of x as a numeric value
atan2(y,x)Arctangent of the quotient of its arguments
ceil(x)Value of x rounded up to its nearest integer
cos(x)Cosine of x (x is in radians)
exp(x)Value of Ex
floor(x)Value of x rounded down to its nearest integer
log(x)Natural logarithm (base E) of x
max(x,y,z,…,n)Number with highest value
min(x,y,z,…,n)Number with lowest value
pow(x,y)X to the power of y
random()Random number between 0 and 1
round(x)Value of x rounded to its nearest integer
sin(x)Sine of x (x is in radians)
sqrt(x)Square root of x
tan(x)Tangent of an angle
JavaScript Regular Expression Syntax – Math Methods
Date()Create a new date object with the current date and time
Date(2017, 5, 21, 3, 23, 10, 0)Create a custom date object. The numbers represent year, month, day, hour, minutes, seconds, milliseconds. You can omit anything you want except for year and month.
Date(“2017-06-23”)Date declaration as a string
getDate()Get the day of the month as a number (1-31)
getDay()Get the weekday as a number (0-6)
getFullYear()Get the year as a four digit number (yyyy)
getHours()Get the hour (0-23)
getMiliseconds()Get the millisecond (0-999)
getMinutes()Get the minute (0-59)
getMonth()Get the month as a number (0-11)
getSeconds()Get the second (0-59)
getTime()Get the time (milliseconds since January 1, 1970)
getUTCDate()Day (date) of the month in the specified date according to universal time (also available for day, month, fullyear, hours, minutes etc.)
parseParse a string representation of a date, and return the number of milliseconds since January 1, 1970
setDate()Set the day as a number (1-31)
setFullYear()Set the year (optionally month and day)
setHours()Set the hour (0-23)
setMiliseconds()Set the milliseconds (0-999)
setMinutes()Set the minutes (0-59)
setMonth()Set the month (0-11)
setSeconds()Set the seconds (0-59)
setTime()Set the time (milliseconds since January 1, 1970)
setUTCDate()Set the day of the month for a specified date according to universal time (also available for day, month, fullyear, hours, minutes etc.)
JavaScript Regular Expression Syntax – Dates
attributesLive collection of all attributes registered to an element
baseURIAbsolute base URL of an HTML element
childNodesCollection of an element’s child nodes
firstChildFirst child node of an element
lastChildLast child node of an element
nextSiblingNext node at the same node tree level
nodeNameName of a node
nodeTypeType of a node
nodeValueValue of a node
ownerDocumentTop-level document object for current node
parentNodeParent node of an element
previousSiblingNode immediately preceding the current one
textContentTextual content of a node and its descendants
JavaScript DOM Mode – Node Properties
appendChild()Add a new child node to an element as the last child node
cloneNode()Clone HTML element
compareDocumentPosition()Compare the document position of two elements
getFeature()Return an object which implements the APIs of a specified feature
hasAttributes()Return true if an element has any attributes, else return false
hasChildNodes()Return true if an element has any child nodes, else return false
insertBefore()Insert a new child node before a specified, existing child node
isDefaultNamespace()Return true if a specified namespaceURI is the default, else return false
isEqualNode()Check if two elements are equal
isSameNode()Check if two elements are the same node
isSupported()Return true if a specified feature is supported on the element
lookupNamespaceURI()Return the namespaceURI associated with a given node
lookupPrefix()Return a DOMString containing the prefix for a given namespaceURI, if present
normalize()Join adjacent text nodes and remove empty text nodes in an element
removeChild()Remove a child node from an element
replaceChild()Replace a child node in an element
JavaScript DOM Mode – Node Methods
getAttribute()Return the specified attribute value of an element node
getAttributeNS()Return string value of the attribute with the specified namespace and name
getAttributeNode()Get the the specified attribute node
getAttributeNodeNS()Return the attribute node for the attribute with the given namespace and name
getElementsByTagName()Provide a collection of all child elements with the specified tag name
getElementsByTagNameNS()Return a live HTML collection of elements with a certain tag name belonging to the given namespace
hasAttribute()Return true if an element has any attributes, else return false
hasAttributeNS()Provide a true/false value indicating whether the current element in a given namespace has the specified attribute
removeAttribute()Remove a specified attribute from an element
removeAttributeNS()Remove the specified attribute from an element within a certain namespace
removeAttributeNode()Take away a specified attribute node and return the removed node
setAttribute()Set or change the specified attribute to a specified value
setAttributeNS()Add a new attribute or change the value of an attribute with the given namespace and name
setAttributeNode()Set or change the specified attribute node
setAttributeNodeNS()Add a new namespaced attribute node to an element
JavaScript DOM Mode – Element Methods
closedCheck whether a window has been closed or not and return true or false
defaultStatusSet or return the default text in the statusbar of a window
documentReturn the document object for the window
framesReturn all <frame> elements in the current window
historyProvide the History object for the window
innerHeightInner height of a window’s content area
innerWidthInner width of the content area
lengthReturn the number of <frame> elements in the window
locationReturn the location object for the window
nameSet or return the name of a window
navigatorReturn the Navigator object for the window
openerReturn a reference to the window that created the window
outerHeightOuter height of a window, including toolbars/scrollbars
outerWidthOuter width of a window, including toolbars/scrollbars
pageXOffsetNumber of pixels by which the document has been scrolled horizontally
pageYOffsetNumber of pixels by which the document has been scrolled vertically
parentParent window of the current window
screenReturn the Screen object for the window
screenLeftHorizontal coordinate of the window (relative to screen)
screenTopVertical coordinate of the window
screenXSame as screenLeft but needed for some browsers
screenYSame as screenTop but needed for some browsers
selfReturn the current window
statusSet or return the text in the statusbar of a window
topReturn the topmost browser window
JavaScript DOM Mode – Browser Window Properties
alert()Display an alert box with a message and an OK button
blur()Remove focus from the current window
clearInterval()Clear a timer set with setInterval()
clearTimeout()Clear a timer set with setTimeout()
close()Close the current window
confirm()Display a dialog box with a message and OK and Cancel buttons
focus()Set focus to the current window
moveBy()Move a window relative to its current position
moveTo()Move a window to a specified position
open()Open a new browser window
print()Print the content of the current window
prompt()Display a dialog box that prompts the visitor for input
resizeBy()Resize the window by the specified number of pixels
resizeTo()Resize the window to a specified width and height
scrollBy()Scroll the document by a specified number of pixels
scrollTo()Scroll the document to specified coordinates
setInterval()Call a function or evaluate an expression at specified intervals
setTimeout()Call a function or evaluate an expression after a specified interval
stop()Stop the window from loading
JavaScript DOM Mode – Browser Window Methods
availHeightReturn the height of the screen (excluding the Windows Taskbar)
availWidthReturn the width of the screen (excluding the Windows Taskbar)
colorDepthReturn the bit depth of the color palette for displaying images
heightThe total height of the screen
pixelDepthThe color resolution of the screen in bits per pixel
widthThe total width of the screen
JavaScript DOM Mode – Screen Properties
onclickWhen user clicks on an element
oncontextmenuWhen user right-clicks on an element to open a context menu
ondblclickWhen user double-clicks on an element
onmousedownWhen user presses a mouse button over an element
onmouseenterWhen user moves pointer onto an element
onmouseleaveWhen user moves pointer away from an element
onmousemoveWhen user moves pointer while it is over an element
onmouseoverWhen user moves pointer onto an element or one of its children
onmouseoutWhen user moves pointer away from an element or one of its children
onmouseupWhen user releases a mouse button while over an element
JavaScript Mouse Events
onkeydownWhen user is pressing a key down
onkeypressWhen user starts pressing a key
onkeyupWhen user releases a key
JavaScript Keyboard Events
onabortWhen loading of media is aborted
onbeforeunloadBefore the document is about to be unloaded
onerrorWhen an error occurs while loading an external file
onhashchangeWhen the anchor part of a URL has changed
onloadWhen an object has loaded
onpagehideWhen user navigates away from a webpage
onpageshowWhen user navigates to a webpage
onresizeWhen user resizes document view
onscrollWhen user is scrolling an element’s scrollbar
onunloadWhen a page has unloaded
JavaScript Frame Events
onblurWhen an element loses focus
onchangeWhen the content of a form element changes (for <input>, <select>, and <textarea>)
onfocusWhen an element gets focus
onfocusinWhen an element is about to get focus
onfocusoutWhen an element is about to lose focus
oninputUser input on an element
oninvalidWhen an element is invalid
onresetWhen a form is reset
onsearchWhen a user types something in a search field (for <input=”search”>)
onselectWhen user selects some text (for <input> and <textarea>)
onsubmitWhen a form is submitted
JavaScript Form Events
ondragWhen user drags an element
ondragendWhen user has finished dragging the element
ondragenterWhen the dragged element enters a drop target
ondragleaveWhen the dragged element leaves the drop target
ondragoverWhen the dragged element is on top of the drop target
ondragstartWhen user starts to drag an element
ondropDragged element is dropped on the drop target
JavaScript Drag Events
oncopyWhen user copies content of an element
oncutWhen user cuts an element’s content
onpasteWhen user pastes content in an element
JavaScript Clipboard Events
onabortWhen media loading is aborted
oncanplayWhen browser can start playing media (e.g. a file has buffered enough)
oncanplaythroughWhen browser can play through media without stopping
ondurationchangeWhen duration of media changes
onendedWhen media has reached its end
onerrorWhen an error occurs while loading an external file
onloadeddataWhen media data is loaded
onloadedmetadataWhen metadata (like dimensions and duration) is loaded
onloadstartWhen browser starts looking for specified media
onpauseWhen media is paused either by user or automatically
onplayWhen media has been started or is no longer paused
onplayingWhen media is playing after having been paused or stopped for buffering
onprogressWhen browser is in the process of downloading media
onratechangeWhen playing speed of media changes
onseekedWhen user has finished moving/skipping to a new position in media
onseekingWhen user starts moving/skipping
onstalledWhen browser is trying to load unavailable media
onsuspendWhen browser is intentionally not loading media
ontimeupdateThe playing position has changed (e.g. because of fast forward)
onvolumechangeWhen media volume has changed (including mute)
onwaitingWhen media has paused but is expected to resume (for example, buffering)
JavaScript Media Events
animationendWhen CSS animation is complete
animationiterationWhen CSS animation is repeated
animationstartWhen CSS animation has started
Animation
transitionendWhen CSS transition is complete
onmessageWhen a message is received through the event source
onofflineWhen browser starts to work offline
ononlineWhen browser starts to work online
onpopstateWhen the window’s history changes
onshowWhen a <menu> element is shown as a context menu
onstorageWhen a Web Storage area is updated
ontoggleWhen user opens or closes the <details> element
onwheelWhen mouse wheel rolls up or down over an element
ontouchcancelWhen screen touch is interrupted
ontouchendWhen user’s finger goes off touch screen
ontouchmoveWhen user drags a finger across the screen
Miscellaneous

Visual Studio Code Shortcuts

Open Command PaletteCtrl + Shift + P
Open app settingsCtrl + ,
Display keyboard shortcutsCtrl + K, Ctrl + S
Switch to Extensions paneCtrl + Shift + X
New fileCtrl + N
New windowCtrl + Shift + N
Close fileCtrl + F4
Close windowCtrl + Shift + F4
Toggle Full ScreenmodeF11
Toggle sidebar visibilityCtrl + B
Visual Studio Code Shortcuts for Basic Functionality
Open fileCtrl + O
Save fileCtrl + S
Save as…Ctrl + Shift + S
Save all filesCtrl + K, S
Close allCtrl + K, Ctrl + W
Reopen last closedCtrl + Shift + T
Visual Studio Code Shortcuts for File Management
Copy selection or current lineCtrl + C
Cut selection or current lineCtrl + X
PasteCtrl + V
Delete lineCtrl + Shift + K
Go to beginning of lineHome
Go to end of lineEnd
Go to beginning of fileCtrl + Home
Go to end of fileCtrl + End
Move line up or downAlt + Up/Down
Indent lineCtrl + ]
Outdent lineCtrl + [
Comment out lineCtrl + /
Comment out regionShift + Alt + A
Visual Studio Code Shortcuts for Editing Commands
Fold regionCtrl + Shift + [
Unfold regionCtrl + Shift + ]
Fold all subregionsCtrl + K, Ctrl + [
Unfold all subregionsCtrl + K, Ctrl + ]
Fold all regionsCtrl + K, Ctrl + O
Unfold all regionsCtrl + K, Ctrl + J
Visual Studio Code Shortcuts for Folding
Go to fileCtrl + P
Go to lineCtrl + G
Show all symbolsCtrl + T
Go to symbolCtrl + Shift + O
Go to next error or warningF8
Go to previous error or warningShift + F8
Show Problems panelCtrl + Shift + M
Go backAlt + Left
Go forwardAlt + Right
Visual Studio Code Shortcuts for Editor Navigation
Open Find dialogCtrl + F
Open Replace dialogCtrl + H
Replaces in filesCtrl + Shift + H
Find nextF3
Find previousShift + F3
Select all matches for search termAlt + Enter
Add current selection to Find matchCtrl + D
Move previous selection to next Find matchCtrl + K, Ctrl + D
Visual Studio Code Shortcuts for Find and Replace
Select current lineCtrl + L
Select all instances of current selectionCtrl + Shift + L
Select all matches of current wordCtrl + F2
Expand selectionShift + Alt + Right Arrow
Shrink selectionShift + Alt + Left Arrow
Insert cursorAlt + Click
Insert cursor above or below current lineCtrl + Alt + Up/Down Arrow
Undo last cursorCtrl + U
Insert cursor at the end of each selected lineShift + Alt + I
Visual Studio Code Shortcuts for Selection and Multiple Cursors
Split editorCtrl + \
Focus on editor pane 1, 2, or 3Ctrl + 1/2/3
Focus on next/previous editor paneCtrl + K, Ctrl + Right/Left Arrow
Move editor leftMove editor left
Move editor rightMove editor right
Visual Studio Code Shortcuts for Split Editor Management
Show integrated terminalCtrl + ‘
Create new terminal instanceCtrl + Shift + ‘
Scroll up/downCtrl + Up/Down Arrow
Scroll to top/bottomCtrl + Home/End
Visual Studio Code Shortcuts for Integrated Terminal
Close fileCmd + W
Toggle full screenCmd + Ctrl + F
Go backCmd + –
Go forwardCmd + Shift + –
Find nextCmd + G
Find previousCmd + Shift + G
Expand selectionCmd + Ctrl + Shift + Right Arrow
Shrink selectionCmd + Ctrl + Shift + Left Arrow
Move editor leftCmd + K, Cmd + Shift + Left
Move editor rightCmd + K, Cmd + Shift + Right
Show integrated terminalCtrl + ‘
Create new terminal instanceCtrl + Shift + ‘
Visual Studio Code Shortcuts for macOS-Specific Shortcuts

Raspberry Pi Commands

CommandResult
cat [name]Show the contents of the file [name]
cd ..Change to parent directory
cd [path]Move to the directory at [path]
cd /Change to root directory
cd ~Change to your home directory – usually “/home/<username>”
chmod [who][+,-,=][permissions] [name]Change the permissions for a file
chmod 777 [name]Allow all users to read, write and execute the file [name]
chmod u+x [name]Allow the user to execute [name]
cp -r [from] [to]Copy all files and subdirectories from source [from] to destination [to]
cp [from] [to]Copy a file from source [from] to destination [to]
findSearch for files and their contents
grep ‘string’ [name]Search inside one or more files for occurrences of ‘string’
head [name]Return all occurrences of ‘string’ within file [name]
lsList the contents of the current directory
ls -aList all files including hidden files
ls -lList the contents of the current directory with more file information
ls [path]List the contents of the directory found at [path]
man [command]Open the manual/help page for [command]
man manOpen the manual/help page for the ‘man’ command (helpception)
mkdir [name]Create a directory called [name] in the current working directory
mv -r [from] [to]Move all files and directories from source [from] to destination [to]
mv [from] [to]Move a file from source [from] to destination [to]
pwdShow the name of the current working directory
python/python3 –versionShows you what version of Python you currently have installed
rm -r *Remove all files and directories from the current working directory
rm [name]Remove the specified file
rm *Remove all files from the current working directory
rmdir [name]Remove the empty directory [name] from the current working directory
sudo [command]Superuser do. Execute [command] with elevated privileges (Allows you to do things you usually wouldn’t have access to)
sudo apt-get install [package]Install a package
sudo apt-get updateUpdate the list of packages
sudo apt-get upgradeUpgrade the installed packages – must be run after sudo apt-get update
sudo chown pi:root [name]Change the owner of the file [name] to user ‘pi’ and set the group to ‘root’
sudo raspi-configLaunch the Raspberry Pi configuration menu
sudo rebootSafely restart your Pi
sudo shutdown -h nowSafely shutdown your Pi immediately
sudo suPlaces you in the root directory with root user access – be careful with this!
tail [name]Show the end of file [name]
tar -cvzf [name] [path]Create compressed file [name] from the contents of [path]
tar -xvzf [name]Extract the contents of the compressed file [name]
wget [uri]Download the file found at [uri] on the internet
Raspbian OS Terminal
CommandResult
import RPi.GPIO as GPIOImport the RPi.GPIO module into the python sketch
GPIO.setmode(GPIO.BCM)Use Broadcom pin numbers (GPIO 14, GPIO 15 etc)
GPIO.setmode(GPIO.BOARD)Use board pin numbers (4,5, 8 etc)
GPIO.getmode()Returns current pin numbering mode (BCM, BOARD, or None)
GPIO.setup([pin number], GPIO.IN)Set up the pin at [pin number] to be an input
GPIO.setup([pin number], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)Set up the pin at [pin number] to be an input with internal pull down resistance
GPIO.setup([pin number], GPIO.IN, pull_up_down=GPIO.PUD_UP)Set up the pin at [pin number] to be an input with internal pull up resistance
GPIO.setup([pin number], GPIO.OUT)Set up the pin at [pin number] to be an output
GPIO.setup([pin number], GPIO.OUT, initial=1)Set up the pin at [pin number] to be an output with the initial value ‘1’
GPIO.output([pin number], 1)Set [pin number]’s value to 1. Note that 1, GPIO.HIGH and True are the same thing
GPIO.output([pin number], 0)Set [pin number]’s value to 0. Note that 0, GPIO.LOW and False are the same thing
i = GPIO.input([pin number])Set the variable i to the value of [pin number]
if GPIO.input([pin number]):Use the value of [pin number] as a boolean in code
GPIO.cleanup()Reset all GPIO pins (good practice to call before leaving any program)
GPIO.VERSIONReturns current RPi.GPIO version
RPi.GPIO Library
CommandResult
LEDs
from gpiozero import LEDImport the LED section of the gpiozero library
led = LED(17)Assign the ‘led’ variable to an LED on pin GPIO 17
led.on()Turn on the LED stored in the ‘led’ variable
led.off()Turn off the LED stored in the ‘led’ variable
led.toggle()Toggle the LED stored in the ‘led’ variable (if it’s off, turn it on and vice versa)
Motors
from gpiozero import MotorImport the Motor section of the gpiozero library
motor = Motor(17, 18)Assign the variable ‘motor’ to a Motor object containing the forward and backward drive pin numbers
motor.forward()Activate the forward pin of the variable ‘motor’
motor.backward()Activate the backward pin of the variable ‘motor’
motor.reverse()Reverse the current motor direction
motor.stop()Stop the motor
Buzzer
from gpiozero import BuzzerImport the Buzzer section of the gpiozero library
bz = Buzzer(3)Assign the variable bz to a Buzzer on pin GPIO3
bz.on()Turn the buzzer on
bz.off()Turn the buzzer off
bz.toggle()Toggle the buzzer’s state (if it’s off, turn it on and vice versa)
Servo
from gpiozero import ServoImport the Servo section of the gpiozero library
servo = Servo(17)Assign the ‘servo’ variable to a Servo on GPIO 17
servo.min()Move the servo to its minimum value
servo.mid()Move the servo to its middle value
servo.max()Move the servo to its maximum value
servo.value = 0.5Move the servo to a set numerical point (min = -1, max = 1)
GPIO Zero Library
CommandResult
raspistillCommand to take a still image with attached camera, modify with arguments below
–width, -wSet image width <size>
–height, -hSet image height <size>
–quality, -qSet JPEG quality <0 to 100> (75 is most common)
–raw, -rInserts raw Bayer data from the camera into the JPEG metadata
–output, -oOutput filename <filename> (required for saving)
–latest, -lAdd latest frame to filename <filename>
–verbose, -vVerbose debugging information during run
–timeout, -tSet a time to wait before capturing an image.
–encoding, -eEncoding to use for output file – jpg, gif, bmp, or png
Raspi Camera Image
raspividCommand to take a video using attached camera, modify with arguments below
–width, -wSet image width <size> (between 64px – 1920px)
–height, -hSet image height <size> (between 64px – 1080px)
–bitrate, -bSet bitrate in bits per second (i.e 15 Mbits/s = 15000000)
–output, -oOutput filename <filename> (required for saving)
–verbose, -vVerbose debugging information during run
–timeout, -tSet a time to wait before capturing video
–framerate, -fpsSpecify the frames per second for recording
Raspi Camera Video

SQL Commands

CommandDescriptionExample
SELECTBasic query building block to retrieve data.SELECT 1 FROM table_name;
SELECT *Using * with SELECT returns all columns.SELECT * FROM table_name;
SELECT columnSpecify exact columns with their name.SELECT column_name FROM table_name;
SELECT table.columnReference a column from a specific table.SELECT table_name.column_name FROM table_name, table_2_name;
FROMSpecify where to find data.SELECT column_name FROM table_name;
ASTemporarily alias a table name or column to a new name.SELECT new_table_name.*, column_name AS new_column FROM table_name AS new_table_name;
WHEREFilter results with a condition.SELECT * FROM table_name WHERE column_name = ‘value’;
ANDUse multiple conditions with a WHERE clause. Results must match all conditions.SELECT * FROM table_name WHERE column_name < 10 AND column_name > 1;
ORUse multiple conditions with a WHERE clause. Results only need to match one condition.SELECT * FROM table_name WHERE column_name < 10 OR column_name = 15;
ORDER BYOrder the results by a column. The database chooses how to order.SELECT * FROM table_name ORDER BY column_name;
ORDER BY column ASCOrder the results by a column in ascending order.SELECT * FROM table_name ORDER BY column_name ASC;
ORDER BY column DESCOrder the results by a column in descending order.SELECT * FROM table_name ORDER BY column_name DESC;
LIMITRestrict the number of results returned.SELECT * FROM table_name LIMIT 5;
OFFSETSkip the first OFFSET number of rows. Often used with LIMIT.SELECT * FROM table_name LIMIT 5 OFFSET 10;
SUBQUERYRun a query to retrieve data for another query.SELECT column FROM table_name where column_name IN (SELECT column_2_name FROM table_2_name);
SQL Query Commands
COUNTCount the number of rows that match the query.SELECT COUNT(column_name) FROM table_name;
MAXReturn the highest value in a numeric column.SELECT MAX(column_name) FROM table_name;
MINReturn the lowest value in a numeric column.SELECT MIN(column_name) FROM table_name;
SUMSum the values of a numeric column.SELECT SUM(column_name) FROM table_name;
AVGCalculate the average value for a numeric column.SELECT AVG(column_name) FROM table_name;
HAVINGUsed with aggregate functions instead of the WHERE clause.SELECT COUNT(column_name) FROM table_name HAVING column_name > 10;
GROUP BYUsed to refine an aggregate result.SELECT COUNT(column_name) FROM table_name GROUP BY column_2_name;
SQL Query Commands for Aggregate Functions
LIKECase-sensitive search for a pattern with a wildcard operator (%).SELECT column_name FROM table_name WHERE column_name LIKE ‘%VALUE%’;
ILIKECase-insensitive search for a pattern with a wildcard operator (%).SELECT column_name FROM table_name WHERE column_name ILIKE ‘%value%’;
BETWEENSearch for a value between two values. Works with dates or numbers.SELECT column_name FROM table_name WHERE column_name BETWEEN 1 AND 10;
>Search for values greater than a condition.SELECT column_name FROM table_name WHERE column_name > 10;
>=Search for values greater or equal to a condition.SELECT column_name FROM table_name WHERE column_name >= 10;
<Search for values less than a condition.SELECT column_name FROM table_name WHERE column_name < 10;
<=Search for values less than or equal to a condition.SELECT column_name FROM table_name WHERE column_name <= 10;
=Search for values matching a condition exactly.SELECT column_name FROM table_name where column_name = 10;
<>Search for values not equal to a condition.SELECT column_name FROM table_name WHERE column_name <> 10;
UNIONCombine two unique queries (with the same columns) into one result.SELECT column_name FROM table_name UNION SELECT column_2_name FROM table_2_name;
UNION ALLCombine two queries (with the same columns) into one result. Duplicates allowed.SELECT column_name FROM table_name UNION ALL SELECT column_2_name FROM table_2_name;
INShorthand for WHERE. Specifies multiple OR conditions.SELECT column_name FROM table_name where column_name IN (‘A’, ‘B’, ‘C’);
NOT INShorthand for WHERE. Specifies multiple OR conditions (inverted) or not equal to.SELECT column_name FROM table_name where column_name NOT IN (‘A’, ‘B’, ‘C’);
IS NULLCheck for empty values.SELECT column_name FROM table_name WHERE column_name IS NULL;
IS NOT NULLCheck for no empty values.SELECT column_name FROM table_name WHERE column_name IS NOT NULL;
INTERSECTReturn results which match two queries.SELECT column_name FROM table_name INTERSECT SELECT column_2_name FROM table_2_name;
MINUSReturn results in one query which are not in another query.SELECT column_name FROM table_name MINUS SELECT column_2_name FROM table_2_name;
SQL Query Commands for Operators
ONUsed to specify the column to compare and match results.SELECT * FROM table_name LEFT OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_name;
USINGShorthand for ON, used when the column name is the same in both tables.SELECT * FROM table_name LEFT OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name;
LEFT OUTER JOINAll the results from the left table, with only the matching results from the right table.SELECT * FROM table_name LEFT OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name;
LEFT OUTER JOIN (WITH NULL)(With null) All the results from the left table but not in the right table.SELECT * FROM table_name LEFT OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name WHERE table_2_name.column_2_name IS NULL;
INNER JOINAll the results that match in both the left and right tables.SELECT * FROM table_name INNER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name;
FULL OUTER JOINAll the results from both the left and right tables.SELECT * FROM table_name FULL OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name;
FULL OUTER JOIN (WITH NULL)(With null) All the results from both the left and right tables excluding results in both tables.SELECT * FROM table_name FULL OUTER JOIN table_2_name ON table_name.column_name = table_2_name.column_2_name WHERE table_name.column_name IS NULL OR table_2_name.column_2_name IS NULL;
RIGHT OUTER JOINAll the results from the right table, with only the matching results from the left table.SELECT * FROM table_2_name RIGHT OUTER JOIN table_name ON table_2_name.column_2_name = table_name.column_name;
RIGHT OUTER JOIN (WITH NULL)(With null) All the results from the right table but not in the left table.SELECT * FROM table_2_name RIGHT OUTER JOIN table_name ON table_2_name.column_2_name = table1.
SQL Query Commands for Joins
CREATE TABLECreate a new table.CREATE TABLE table_name (column_name datatype column_2_name datatype);
NULLAllow empty values for this field.CREATE TABLE table_name (column_name column_name datatype NULL);
NOT NULLDon’t allow empty values for this field.CREATE TABLE table_name (column_name column_name datatype NOT NULL);
DEFAULTA value to populate the field with if one is not supplied.CREATE TABLE table_name (column_name datatype DEFAULT ‘makeuseof’);
ASCreate a new table based on the structure of an existing table. The new table will contain the data from the old table.CREATE TABLE table_2_name AS SELECT * FROM table_name;
ALTER TABLE (ADD COLUMN)Add a new column to an existing table.ALTER TABLE table_name ADD COLUMN column_2_name datatype;
ALTER TABLE (DROP COLUMN)Remove a column from an existing table.ALTER TABLE table_name DROP COLUMN column_2_name;
ALTER TABLE (ALTER COLUMN)Change the datatype of an existing column.ALTER TABLE table_2_name ALTER COLUMN column_name datatype;
ALTER TABLE (RENAME COLUMN)Rename an existing column.ALTER TABLE table_name RENAME COLUMN column_name TO new_column_name datatype;
ALTER TABLE (RENAME TABLE)Rename an existing table.RENAME TABLE table_name TO new_table_name;
ALTER TABLE (MODIFY NULL)Allow null values for a column.ALTER TABLE table_name MODIFY column_name datatype NULL;
ALTER TABLE (MODIFY NOT NULL)Prevent null values for a column.ALTER TABLE table_name MODIFY column_name datatype NOT NULL;
DROP TABLEDelete a table and all its data.DROP TABLE table_name;
TRUNCATE TABLEDelete all the data in a table, but not the table itself.TRUNCATE TABLE table_name;
SQL Query Commands for Creating and Editing Tables
PRIMARY KEYA value that uniquely identifies a record in a table. A combination of NOT NULL and UNIQUE.CREATE TABLE table_name (column_name datatype column_2_name datatype, PRIMARY KEY (column_name, column_2_name));
FOREIGN KEYReferences a unique value in another table. Often a primary key in the other table.CREATE TABLE table_name (column_name datatype column_2_name datatype, FOREIGN KEY (column_name) REFERENCES table_2_name (column_2_name));
UNIQUEEnforce unique values for this column per table.CREATE TABLE table_name (column_name datatype column_2_name datatype, UNIQUE(column_name, column_2_name));
CHECKEnsure values meet a specific condition.CREATE TABLE table_name (column_name datatype column_2_name datatype, CHECK(column_name > 10));
INDEX (CREATE)Optimize tables and greatly speed up queries by adding an index to a column.CREATE INDEX index_name ON table_name(column_name);
INDEX (CREATE UNIQUE)Create an index that does not allow duplicate values.CREATE UNIQUE INDEX index_name ON table_name(column_name);
INDEX (DROP)Remove an index.DROP INDEX index_name;
SQL Query Commands for Constraints
INSERT (SINGLE VALUE)Add a new record to a table.INSERT INTO table_name(column_name) VALUES(value_1);
INSERT (MULTIPLE VALUES)Add several new records to a table.INSERT INTO table_name(column_name) VALUES(value_1),(value_2);
INSERT (SELECT)Add records to a table, but get the values from an existing table.INSERT INTO table_name(column_name) SELECT * FROM table_2_name;
UPDATE (ALL)Modify all existing records in a table.UPDATE table_name SET column_name = 10;
UPDATE (WHERE)Modify existing records in a table which match a condition.UPDATE table_name SET column_name = 10 WHERE column_2_name = 5;
DELETE (ALL)Remove all records from a table.DELETE FROM table_name;
DELETE (WHERE)Remove records from a table which match a condition.DELETE FROM table_name WHERE column_name = 5;
SQL Query Commands for Creating and Editing Data
CREATE TRIGGERCreate a trigger.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
CREATE TRIGGER (OR MODIFY)Create a trigger, or update an existing trigger if one is found with the same name.CREATE OR MODIFY TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
WHEN (BEFORE)Run the trigger before the event happens.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
WHEN (AFTER)Run the trigger after the event happens.CREATE TRIGGER trigger_name AFTER INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
EVENT (INSERT)Run the trigger before or after an insert happens.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
EVENT (UPDATE)Run the trigger before or after an update happens.CREATE TRIGGER trigger_name BEFORE UPDATE ON table_name FOR EACH ROW EXECUTE stored_procedure;
EVENT (DELETE)Run the trigger before or after a delete happens.CREATE TRIGGER trigger_name BEFORE DELETE ON table_name FOR EACH ROW EXECUTE stored_procedure;
ONSpecify which table to target with this trigger.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
TRIGGER_TYPE (FOR EACH ROW)Execute the trigger for every row changed.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
TRIGGER_TYPE (FOR EACH STATEMENT)Execute the trigger once per SQL statement, regardless of how many rows are altered.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW STATEMENT stored_procedure;
EXECUTEKeyword to indicate the end of the main trigger definition.CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW EXECUTE stored_procedure;
DROP TRIGGERDelete a trigger.DROP TRIGGER trigger_name;
SQL Query Commands for Creating and Editing Triggers
CREATE VIEWCreate a new view.CREATE VIEW view_name(column_name) AS SELECT * FROM table_name;
ASDefine where to retrieve the data for a view.CREATE VIEW view_name(column_name) AS SELECT * FROM table_name;
WITH CASCADED CHECK OPTIONEnsure any data modified through a view meets the rules defined by the rule. Apply this to any other views.CREATE VIEW view_name(column_name) AS SELECT * FROM table_name WITH CASCADED CHECK OPTION;
WITH LOCAL CHECK OPTIONEnsure any data modified through a view meets the rules defined by the rule. Ignore this for any other views.CREATE VIEW view_name(column_name) AS SELECT * FROM table_name WITH LOCAL CHECK OPTION;
CREATE RECURSIVE VIEWCreate a recursive view (one that refers to a recursive common table expression).CREATE RECURSIVE VIEW view_name(column_name) AS SELECT * FROM table_name;
CREATE TEMPORARY VIEWCreate a view that exists for the current session only.CREATE TEMPORARY VIEW view_name(column_name) AS SELECT * FROM table_name;
DROP VIEWDelete a view.DROP VIEW view_name;
SQL Query Commands for Creating and Editing Views
WITHCreate a new common table expression.WITH cte_name (column_name) AS (SELECT * FROM table_name) SELECT * FROM cte_name;
ASSpecify the data to use in the CTE.WITH cte_name (column_name) AS (SELECT * FROM table_name) SELECT * FROM cte_name;
,(COMMA)Chain multiple CTEs.WITH cte_name (column_name) AS (SELECT * FROM table_name), cte_2_name (column_2_name) AS (SELECT * FROM table_2_name) SELECT * FROM cte_name;
SQL Query Commands for Common Table Expressions (CTEs)

Python RegEx Shortcuts

pip install packageInstall an online librarypip install pandas
virtualenv nameUse virtaulenv to create a virtual environmentvirtualenv myproject
mkvirtualenv nameUse virtual environment wrapper to create virtual environmentmkvirtualenv myproject
python file.pyRun the commands in a Python file“python my_file.py
pip freezeList out all the installed packages in a virtual environmentpip freeze
pip freeze > somefilesCopy all installed libraries in a single filepip freeze > requirements.txt
whereFind the installation path of Pythonwhere python
–versionCheck the version of a packagepython –version
.exeRun a Python shellpython.exe
with open(file, ‘w’)Write to an existing file and overwrite its existing contentwith open(‘regex.txt’, ‘w’) as wf: wf.write(“Hello World!”)
with open(file, ‘r’)Open a file as read-onlywith open(‘regex.txt’, ‘r’) as rf: print(rf.read()
with open(file, ‘a’)Write to a file without overwriting its existing contentwith open(‘regex.txt’, ‘a’) as af: af.write(“\nHello Yes!”)
file.closeClose a file if it’s not in useaf=open(‘regex.txt’)
af.close
exitExit the Python shellexit()
Python Command Line
ExpressionActionExample
print()Display the result of a commandx=”Hello world”
print(x)

output: Hello world

input()Collect inputs from usersprint(input(“what is your name?”))

output: what is your name?

type()Find the type of a variablex=”Regular expressions”
type(x)

output: <class ‘str’>

len()Find the number of items in a variablelen([1, 2, 3])

output: 3

\Escape a character that changes the intent of a line of codeprint(“I want you to add\”\””)

output: I want you to add””

\nBreak a string character to start on the next lineprint(“This is a line \n This is a second line”)

output: This is a line This is a second line

def function_name(parameter): commandsInitiate a function with an optional parameterdef yourName(x):
print(x+1)
lambdaCall an anonymous functionadd_3_to = lambda y:
y+3
print(add_3_to(4))

output: 7

returnReturn a result from a functiondef yourName(x):
return x+1
classCreate a Python objectclass myClass:
def myFunc(x):
def _init_Initialize the attrributes of a classclass myClass:
def _init_(self, attributes…)
“_init_.pySave a file containing a module so that it’s read successfully in another Python fileRename a file containing a module as:
“_init_.py
int()Convert a variable to integerint(1.234)

output: 1

str()Convert a variable to stringstr(1.234)

output: ‘1.234’

float()Convert a variable to floatfloat(23)

output: 23.0

dict(Counter())Convert a list or a tupple into a dictionary after sorting with a Python built-in Counterfrom collections import Counter dict(Counter([1,1,2,1,2,3,3,4]))

output: {1: 3, 2: 2, 3: 2, 4: 1}

round()Round up the output of an operation to the nearest whole numberround(23.445)

output: 23

round(operation or number, decimal places)Round up the output of an operation to a specific number of decimal placesround(23.4568, 2)

output: 23.46

if:Initiate a conditional statementif 2<3:
print(“Two is smaller”)
elif:Make a counterstatement when the if statement is Falseif 2<3:
print(“Two is smaller”) elif 2==3:
print(“Go on”)
else:Make a final counterstatement if other conditions are Falseif 2<3:
print(“Two is smaller”) elif 2==3:
print(“Go on”) else:
print(“Three is greater”)
continueIgnore a condition and execute the rest of the loopa=[1, 4, -10, 6, 8] for b in a:
if b<=0:
continue print(b)

output: 1 4 6 8

breakTerminate the flow of a loop with a given conditiona=[1, 4, -10, 6, 8] for b in a:
if b>=6:
break print(b)

output: 1 4 -10

passIgnore a set of prior instructionsfor b in a:
pass
try, exceptTry a block of code, else, raise a defined exceptiontry:
print(a) except:
print(“An error occured!”)

output: An error occured!

finallyExecute a final code when the try and the except blocks failtry:
print(a) except:
print(d) finally:
print(“You can’t print an undefined variable”)

output: You can’t print an undefined variable

raise Exception()Raise an exception that stops the command when execution isn’t possiblea=7+2
if a<10:
raise Exception(“Oh! You didn’t get a score of 10”)
import xImport a whole module or libraryimport math
from x import yImport a library x from a file, or a class yfrom scipy.stats import mode
asCustomize an expression to your preferred nameimport pandas as pd
inCheck if a value is present in a variablex=[1, 4, 6, 7] if 5 in x:
print(“There is a five”) else:
print(“There is no five”)

output: There is no five

isCheck if two variables refer to a single elementx=[1, 4, 6, 7]
x=b
print(x is b)
True
NoneDeclare a null valuex=None
<Check if one value is lesser than another5<10
output: True
>Check if one value is more than another5>10
output: False
<=Check if a value is lesser or equal to another2*2<=3
output: False
>=Check if a value is greater or equal to another2*2>=3
output: True
“==Check if a value is exactly equal to the other3==4

output: False

!=Ascertain that a value is not equal to the other3!=4

output: True

import reImport Python’s built-in regular expressionsimport re
re.findall(“strings”, variable)
a|bCheck if either of two elements are present in a stringimport re
someText=”Hello regular expression”
a=re.findall(“regular|Hello”, someText)
print(a)

output: [‘Hello’, ‘regular’]

string$string$Check if a variable ends with a set of strings
import re
someText=”Hello regular expression”
a=re.findall(“expression$”, someText)

output: [‘expression’]

^stringCheck if a variable starts with a set of stringsimport re
someText=”Hello regular expression”
a=re.findall(“^Hello”, someText)
print(a)

output: [‘Hello’]

string.index()Check the index position of a string charactera= “Hello World”
a.index(‘H’)

output: 0

string.capitalize()Capitalize the first character in a set of stringsa= “Hello World”
a.capitalize()

output: ‘Hello world’

string.swapcase()Print the first letter of each word as a lower case and the others as upper casea= “Hello World”
a.swapcase()

output: ‘hELLO wORLD’

string.lower()Convert all the strings to a lowercasea= “Hello World”
a.lower()

output: ‘hello world’

string.upper()Convert all strings to uppercasea= “Hello World”
a.upper()

output: ‘HELLO WORLD’

string.startswith()Check if a string starts with a particular charactera= “Hello World”
a.startswith(‘a’)

output: False

string.endswith()Check if a string ends with a particular charactera= “Hello World”
a.endswith(‘d’)

output: True

string.split()Separate each word into a lista= “Hello World”
a.split()

output: [‘Hello’, ‘world’]

strings {}’.format()Display an output as stringa=3+4
print(“The answer is {}”.format(a))

output: The answer is 7

is not NoneCheck if the value of a variable is not emptydef checknull(a):
if a is not None:
return “its full!” else:
return “its empty!”
x%yFind the remainder (modulus) of a division9%4

output: 1

x//yFind the quotient of a division9//4

output: 2

“=Assign a value to a variablea={1:5, 3:4}
“+Add elements together[“a two”] + [“a one”]
output: [‘a two’, ‘a one’]
1+3

output=4

“-Find the difference between a set of numbers3-4

output=-1

“*Find the product of a set of numbers3*4

output:12

a+=xAdd x to variable a without assigning its value to a new variablea=2
a+=3

output: 5

a-=xSubsract x from variable a without assigning it to a new variablea=3
a-=2

output: 1

a*=xFind the product of variable a and x without assigning the resullt to a new variablea=[1, 3, 4]
a*=2

output: [1, 3, 4, 1, 3, 4]

x**yRaise base x to power y2**3

output: 8

pow(x, y)Raise x to the power of ypow(2, 3)

output: 8

abs(x)Convert a negative integer to its absolute valueabs(-5)

output: 5

x**(1/nth)Find the nth root of a number8**(1/3)

output: 2

a=b=c=d=xAssign the same value to multiple variablesa=b=c=d=”Hello world”
x, y = y, xSwap variablesx = [1, 2]
y = 3
x, y = y, x
print(x, y)

output: 3 [1, 2]

forLoop through the elements in a variablea=[1, 3, 5]
for b in a:
print(b, “x”, “2”, “=”, b*2)

output:
1 x 2 = 2
3 x 2 = 6
5 x 2 = 10

whileKeep looping through a variable, as far as a particular condition remains Truea=4
b=2
while b<=a:
print(b, “is lesser than”, a)
b+=1

output:
2 is lesser than 4
3 is lesser than 4
4 is lesser than 4

range()Create a range of positive integers between x and yx=range(4)
print(x)
range(0, 4) for b in x:
print(b)

output:
0
1
2
3

sum()Iterate through the elements in a listprint(sum([1, 2, 3]))

output:6

sum(list, start)Return the sum of a list with an added elementprint(sum([1, 2, 3], 3))

output: 9

[]Make a list of elementsx=[‘a’, 3, 5, ‘h’, [1, 3, 3], {‘d’:3}]
()Create a tupple—tupples are immutablex=(1, 2, ‘g’, 5)
{}Create a dictionarya={‘x’:6, ‘y’:8}
x[a:b]Slice through a listx=[1, 3, 5, 6]
x[0:2]

output: [1, 3]

x[key]Get the value of a key in dictionary xa={‘x’:6, ‘y’:8}
print(a[‘x’])

output: 6

x.append()Add a list of values to an empty listx=[1]
x.append([1,2,3])
print(x)

output: [1, [1,2,3]]

x.extend()Add a list of values to continue an existing list without necessarily creating a nested listx=[1,2]
x.extend([3,4,6,2])
print(x)

output: [1, 2, 3, 4, 6, 2]

del(x[a:b])Delete an item completely from a list at a specific indexx=[1,2,3,5]
del(x[0:2])
print(x)

output: [2,3,5]

del(x[key])Delete a key and a value completely from a dictionary at a specific indexy={1:3, 2:5, 4:6, 8:2}
del(y[1], y[8])
print(y)

output= {2:5, 4:6}

dict.pop()Pop out the value of a key and remove it from a dictionary at a specific indexa={1:3, 2:4, 5:6}
a.pop(1)

output: 3

dict.popitem()Pop out the last item from a dictionary and delete ita={1:2, 4:8, 3:5}
a.popitem()
output: (3, 5)
print(a)

output: {1:2, 4:8}

list.pop()Pop out a given index from a list and remove it from a lista=[1, 3, 2, 4, 1, 6, 6, 4]
a.pop(-2)
output: 6
print(a)

output: [1, 3, 2, 4, 1, 6, 4]

clear()Empty the elements of a list or a dictionaryx=[1, 3, 5]
x.clear()
print(x)

output: []

remove()Remove an item from a listx=[1, 5, 6, 7]
x.remove(1)
output: [5, 6, 7]
insert()Insert elements into a listx=[3, 5, 6]
x.insert(1, 4)
print(x)

output: [1, 4, 3, 5, 6]

sort(reverse=condition)Reverse the direction of the elements in a listx=[1, 3, 5, 6]
x.sort(reverse=True)
print(x)

output: [6, 5, 3, 1]

update()Update a dictionary by changing its first element and adding any other item to its endx={1:3, 5:6}
x.update({1:4, 8:7, 4:4})
print(x)

output: {1: 4, 5: 6, 8: 7, 4: 4}

keys()Show all the keys in a dictionarya={1:2, 4:8}
a.keys()

output: dict_keys([1, 4])

values()Show all the values in a dictionarya={1:2, 4:8}
a.values()

output: dict_values([2, 8])

items()Display the keys and the values in a dictionarya={1:2, 4:8}
a.items()

output: dict_items([(1, 2), (4, 8)])

get(key)Get the value of an item in a dictionary by its keya={1:2, 4:8, 3:5}
a.get(1)

output: 2

setdefault(key)Return the original value of an element to a dictionarya.setdefault(2)
f={**a, **b}Merge two dictionariesa={‘x’:6, ‘y’:8}
b={‘c’:5, ‘d’:3}
f={**a, **y}
print(f)

output:{‘x’: 6, ‘y’: 8, ‘c’: 5, ‘d’: 3}

remove()Remove the first matching value of an element from a list without minding its indexa=[1, 3, 2, 4, 4, 1, 6, 6, 4]
a.remove(4)
print(a)

output: [1, 3, 2, 4, 1, 6, 6, 4]

memoryview(x)Access the internal buffers of an objecta=memoryview(object)
bytes()Convert a memory buffer protocol into bytesbytes(a[0:2])
bytearray()Return an array of bytesbytearray(object)
#Write a single line of comment or prevent a line of code from being executed# Python regex cheat sheet
“”””””Write a multi-line comment“””The Python regex cheat sheet is good for beginners It’s equally a great refresher for experts”””
Python RegEx