+=add
-=Subtract or Negative
*=Multiply
/=division (rounded to the nearest whole number)
**=exponation
To assiagn a variable example x=2
= is the operator for variable assignment
(variable)=(expression)
Expression: Anything that Evaluates to a single Value... 1+1 is an expression
== is the Comparision operator for Equality
== doesent assign a value to anything it merely does a check to see if the value which is a variable assignment
if statment: if <condition>: <indented lines of code>
>>> x = 5 + 5
>>> if x == 9:
... haha = 12
... print True
>>> if x == 10:
... haha = 13
... print True
True
>>> print haha
13
Boolean Value 0=false 1,2,etc would be true
elif= else if, it comes rite after an if statment and it means " If the above statment is false, then check to see if this statment is true
but if the above statment is true then it skips the elif statment alltogethor
"if-elif-else" statment is when you have multiple statmens. firstatment is an if, middle statment is an elsif, last is an else
while 1: print "Hello, World!"(funny)
== can work be done on string comparisions
While Statments are like If statments except they continuasily loop as long as their condition is true
Arbritray: without regard, you can put anything that evaluetes to a value
Container objects/elements/items
The list, this is a basic syntax x = [1, 2, 3, 4, 5, 6]
the hole thing is in brackets, everything seperated by commas
it can do an operation inside a statment, example ThisList = [1, 2, 3, 4, 5 + (x * 5)
To specify which number inside the variable, we use a slice notation to reference it
example: if x == [a, b, c, d, e] then x[0] == a
x[1] == b x[2] == c , ETC
you can type x[0] and it would show you the value or x[0] == "a" and it would say true
the little numbers in the brackets are called an "index"... or "indices" which is the plural of index)
x[-1] - numbers ascend from right to left while positive ascend left to right
x[-1] == x[3]
the colon is what separates the start index from the end index example x[3:4] only spans across one item in
the list. If you think of the indices as little line going between the items
for letter in x: *hit enter
print letter this called itenerery
the for statement syntax looks like this. for <variable> in <list>, num was <variable>, and x was <list>
for x in range(1, 100): #<-- range function creates a list of numbers
print str(x) + " bottles of beer on the wall..." #<-- str function converts x to a string
Example program for finding the square of the first 6 numbers
>>> x = [1, 2, 3, 4, 5, 6]
>>> for num in x:
print num ** 2
1
4
9
16
25
36
>>>
\end of exmample\
range: range(1 , 7) would make a list with 1,2,3,4,5,6
\end of example\
a function is something that takes in a number of values (called arguments, or parameters) as input...
and performs a block of code with those values.