Python
Variables
Can represent numeric values, characters, character strings, or memory addresses.
What is sys.argv?
It allows you to input parameters from the command line.
%r
String (converts any Python object using repr())
boolean value
True or False
Syntax
the grammar, structure, or order of the elements in a language statement.
What does % when printing string
they allow the variables outside the string to enter into the string
String
can contain letters, numbers, and symbols
%r is used for...
debugging and display
%s is used for
display
==
equal to
**
exponent
What's the difference between = and == in Python? = is the assignment operator. == is the equality operator.
= is the assignment operator. == is the equality operator.
"
Double Quotes
modulo
%. Returns the remainder from a division.
modules
-aka libraries -feature sets you can import into a program
A for-loop is...
...
str()
...
%s
Converts String (converts any Python object using str())
%d
Converts a signed integer decimal
def
Defines a function def function1(): print "this is function 1"
#
Denotes a comment in a program.
input() function
How the player will enter text into the program through the keyboard
'
Single Quotes
Expression
In a programming language is a combination of explicit values, constants, variables, operators, and functions that are interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then produces another value
raw_input()
Raw input prompts the user for an input and then turns that input into a string. In between "(" and ")" the programmer writes the prompt that will prompt the user. When you set raw_input() equal to a variable, that variable becomes what the user inputs.
.py
The file extension that denotes a python file.
if
Used to determine, which statements are going to be executed
print()
Used to display a string on the screen. Takes the string you type in between the parentheses as input and displays the text on the screen.
What is the ' and " used for
What is put around strings
+
You can add one string to the end of another by using this operator.
A while-loop is...
an infinite loop. "while True" ~ "While true is true, run this:"
import
import other modules into a python script
integer vs. float
integer is a number w/out a decimal; float is a number with a decimal
<, <=, >, >=
less than, less than or equal to, greater than, greater than or equal to
^
matches the beginning of a string
$
matches the end of a string
!=
means doesn't equal
Function
mini program inside your computer
\n
moves whatever is after it to a new line
else
optional. Used after elif to catch other cases not provided for.
my_list.sort()
sorts a list from lowest to highest, or alphabetical
elif
stands for else if. if the first test evaluates to False, continues with the next one
\
tells Python not to end the string