-
-
Save akaomy/bf66374dd70cac3d2104e4bb48d775f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go back through every exercise you have done so far and write down every word and symbol | |
(another name for "character") that you have used. | |
Make sure your list of symbols is complete. | |
Next to each word or symbol, write its name and what it does. | |
print() - The print() function writes the value of the argument(s) it is given | |
# - one line comment | |
""" """ - multiple lines comment | |
+ - addition | |
- - substraction | |
/ - division, continuation character | |
* - multiplication | |
% - remainder | |
< - less-than | |
> - greater-than | |
<= - less-than-equal | |
>= - greater-than-equal | |
"car = 3" - create variable and assign value. in this case we assign int | |
%s - String (converts any Python object using str()); take var on the right and put it in to replace the %s with its value | |
%r - String (converts any Python object using repr()). | |
$d - Signed integer decimal | |
round() - method which is rounding numbers to whole number | |
"word" - string | |
'word' - string | |
True / False - boolean | |
\n - new line | |
\ - escape character | |
input() - returns the exact string | |
raw_input() - doesn't exit in python 3.x | |
int() - converts to int | |
str() - converts to string | |
"%s %s" % (var1, var2) - when there is more than one argument use -> | |
modules - allows logically organize your code. it's a python object with arbitrarily named attributes | |
that you can bind and reference. Can include defined functions, classes and variables or | |
runnable code | |
import - you can use any python source file as a module by executing an import statement in some | |
other Python source file | |
from...import - lets import specific attributes from a module into the current namespace | |
from...import* - import all names from a module into the current namespace | |
argv (from sys) - argument variable. this variable hold the arguments you pass to your Python scritp when | |
you run it | |
open() - open a file | |
close() - closes the file. Like "File->Save.." in your editor | |
read() - reads the content of your file. You can assign the results to a variable | |
readline() - reads just one line of a text | |
truncate() - epties the file. watch out if you care about the file | |
seek() - | |
write('stuff') - writes "stuff" to the file | |
open(fname, 'w'/'r'/'a'): | |
"w" - truncate file to zero length or creae text file for writing | |
"r" - open text file for reading | |
"a" - open for writing. the file is created if it doesn't exist | |
echo - display | |
cat - display file container | |
len() - length of variable's value | |
def - for "define" function | |
(args*) - take all arguments to the function and then put them in args as a list | |
a function - piece of code that is called by name. It can be passed data to operate on and can | |
optionally return data. All data that is passed to a function is explicitly passed. | |
a method - is a piece of code that is called by name that is associated with an object. in most cases | |
it's identical to a function except two key differences: | |
1. A method is implicitly passed the object on which it was called. | |
2. A method is able to operate on data that is contained within the class (remembering that | |
an object is an instance of a class - the class is the definition, the object is an instance | |
of that data) | |
t = () - tuple, immutable | |
r = [] - list | |
d = {"key": "value"} - dictionary | |
parameter - is a variable in a menthod definition / in the declaration od function. | |
argument - when a method is called, the arguments are the data you pass into tha method's parameters. | |
argument is the actual value of this variable that gets passed to function. | |
some practise examples: | |
name = "Kate" | |
number = 32 | |
print("Her name is %s and her age is %d") % (name, age) => Her name is Kate and her age is 32 | |
test = "some var" | |
print("This is test for %s") % test => This is test for some var | |
someFunction(20+30, 40-10) | |
someFunction(var1 + 10, var2 - 20) | |
someFunction(var1, var2) | |
someFunction(29, 67) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment