-
print
- Name: print
- What it does: prints out string we input
-
#
- Name: octothorpe, pound, hash
- What it does: allows you to comment on the code, anything after the # is ignored by python
-
+
- Name: plus
- What it does: addition
-
-
- Name: minus
- What it does: subtraction
-
/
- Name: slash
- What it does: division
-
*
- Name: asterisk
- What it does: multiplication
-
%
- Name: modulus
- What it does: for math, it is the remainder of the division
-
<
- Name: less-than
- What it does: Finds whether true or false whether X is less-than Y
-
>
- Name: greater-than
- What it does: Finds whether true or false whether X is greater-than Y
-
<=
- Name: less-than-equal
- What it does: Finds whether true or false whether X is less-than or equal-to Y
-
>=
- Name: greater-than-equal
- What it does: Finds whether true or false whether X is greater-than or equal-to Y
-
=
- Name: single-equal
- What it does: assigns value on the right to a variable on the left. Variables need to start with a character (not a number)
-
==
- Name: double-equal
- What it does: tests if two things have the same value
-
"string %s" % variable
- Name: format string
- What it does: embed variables in a string using specialized format sequences, and putting variables at end with special syntax. If you want multiple formats in your string to print multiple variables, you need to put them inside a ( ) (parenthesis) separated by , (commas).
-
%s
- Name: s formatter
- What it does: displays variables for users
-
round()
- Name: round function/command
- What it does: rounds numbers
-
'
- Name: single-quote
- What it does: putting two single-quotes around text creates a string
-
"
- Name: double-quote
- What it does: putting two double-quotes around text creates a string
-
%r
- Name: r formatter
- What it does: for debugging, displays the "raw" data of the variable. Also known as the "representation"
-
%d
- Name: d formatter
- What it does: displays variables in decimal numery system for users
-
""" or '''
- Name: triple double- or single-quotes
- What it does: allows you to create a string that only ends when you put another tripe double- or single- quote
-
\\
- Name: Backslash()
- What it does: An escape sequence that inserts a backslash in a string
-
\'
- Name: single quote (')
- What it does: An escape sequence that inserts a single quote in a string
-
\"
- Name: Double quote (")
- What it does: An escape sequence that inserts a double quote in a string
-
\a
- Name: ASCII Bell (BEL)
- What it does: An escape sequence that inserts a beep noise in a string
-
\b
- Name: ASCII Backspace (BS)
- What it does: An escape sequence that inserts a backspace in a string
-
\f
- Name: ASCII Formfeed (FF)
- What it does: An escape sequence that inserts a new page for a printer (and ejects current page) in a string ???
-
\n
- Name: Linefeed (LF)
- What it does: An escape sequence that inserts a new line in a string
-
\N{name}
- Name: Character named name in the Unicode database (Unicode only)
- What it does: An escape sequence that ???
-
\r ASCII
- Name: Carriage Return (CR)
- What it does: An escape sequence that inserts a return in the string
-
\t ASCII
- Name: Horizontal Tab (TAB)
- What it does: An escape sequence that inserts a horizontal tab in the string
-
\uxxxx
- Name: Character with 16-bit hex value xxxx (Unicode only)
- What it does: An escape sequence that ??? in the string
-
\uxxxxxxxx
- Name: Character with 32-bit hex value xxxx (Unicode only)
- What it does: An escape sequence that ??? in the string
-
\v
- Name: ASCII Vertical Tab (VT)
- What it does: An escape sequence that inserts a vertical tab in the string
-
\ooo
- Name: Character with octal value ooo
- What it does: An escape sequence that inserts a character with octal value ooo in the script
-
\xhh
- Name: Character with hex value hh
- What it does: An escape sequence that inserts a character with hex value hh in the script
-
,
- Name: comma
- What it does: if inside a script, makes sure the print command doesn't end the line with a newline and go to the next one
-
raw_input()
- Name: raw input command
- What it does: allows you to input a string into the script/code. You can also put a prompt within the parenthesis to show a person so they know what to type.
-
int()
- Name: integer command
- What it does: converts user input into an integer
-
input()
- Name: input command
- What it does: convert things you enter as if they were Python code, but has security problems so you should avoid it
-
python -m pydoc x
- Name: pydoc command
- What it does: Python gives information on x
-
from sys import argv
- Name: script that accepts arguments
- What it does: pass arguments as variables into script. Import allows you to add modules to your script from the Python feature set.
-
import
- Name: import command
- What it does: adds modules to your script from the Python feature set
-
argv
- Name: argument variable
- What it does: allows variables to hold arguments you pass to Python script when you run it. "Unpack" assigned variables to the left of the = argv in order. The user is required to give input arguments
-
sys
- Name: sys module
- What it does: It is a "package" ???
-
open()
- Name: open command
- What it does: opens the file for commands that you can give it. Without parameter the command opens file in 'r' (read) mode. The "w" parameter (filename, 'w') opens file in writing mode, and the 'a' paramter opens file in append mode. The + modifier expand the file modes: 'w+', 'r+', and 'a+' opens file in both read and write mode, and depending on character positions the file in different ways.
-
read()
- Name: read command
- What it does: allows user to read file
-
.
- Name: dot or period
- What it does: you give a file a command by using the period after the file, the name of the command, and the parameters of the command
-
close()
- Name: close command
- What it does: closes the opened file
-
readline()
- Name: reads line command
- What it does: reads just one line of a text file given parameters. Inside the command is code that scans each byte of a file until it finds a \n character, then stops reading the file to return what it found so far. The file in the parenthesis is responsible for maintaining the current position in the file after each readline() command.
-
truncate()
- Name: truncate command
- What it does: empties the file
-
write()
- Name: write command
- What it does: writes stuff in parenthesis into file
-
from os.path import exists
- Name:
- What it does: imports the exists command from the os.path package
-
exists()
- Name: exists command
- What it does: Based on the file's name in a string as an argument, the exists command returns True if a file exists and False if not.
-
len()
- Name: length command
- What it does: gets the length of the string that you pass to it then returns that as a number
-
def function_name(arguments)
- Name: functions
- What it does: Create functions by using def (define). We run/use/call functions. Function names cannot start with numbers. Functions do three things. 1) Name pieces of code the way variables name strings and numbers. 2) Take arguments the way your scripts take argv. 3) Allows you to make your own "mini scripts" or "tiny commands". The lines after the first in the function script must be indented 4 spaces. To end the function script you must "dedent". Use *args (asterisk args) in the parenthesis to have same use as the argv parameter but for functions. Must end the def line with a colon, and then indent. The variables in functions are not connected to variables in the script.
-
seek()
- Name: seek command
- What it does: Files in Python has a "read head", and you can "seek" this read head around the file to different positions. Each time you do seek(0), you're moving to the start of the file. The seek command is dealing in bytes (not lines). The 0 byte is the first byte in the file.
-
+=
- Name: plus minus
- What it does: contraction for two operations = and +. x = x + y is the same as x += y.
-
return
- Name: return
- What it does: allows variables to be a value from a function
|
|