Reserved Words Word Scramble
|
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Term | Definition |
multiply | 2*3 = 6 |
integer | Values without the decimal point int |
floating point | Values with decimal points and fractional parts float |
precedence rules | Multiplication and division before Addition and Subtraction. Parentheses explicitly specify the order in which operations should take place. Expressions are evaluated from left-to-right. PEMDAS : Please Excuse My Dear Aunt Sally |
exponents | 2**3 = 8 |
divide | 6/2 = 3 |
integer quotient | 14//4 = 3 the number of whole times 3 goes into 14 |
remainder | 14%3 = 2 the remainder when 14 is divided by 3 |
absolute value | abs(5) = 5 abs (-7) = 7 distance from zero on number line |
minimum | min(18, 5) = 5 returns the lesser number |
maximum | max (19, 5) = 19 returns the greater number |
algebraic expressions | evaluate to a number, whether of type int or float or one of the other number types that Python supports. |
Boolean expressions | evaluate to one of two values: True or False. These values are said to be of Boolean type denoted bool |
not | Comparison operators 4 != 5 True |
greater than | Comparison operators 5>4 True |
less than | Comparison operators 5<6 True |
equal to | Comparison operators 5 == (25/5) True |
less than or equal to | Comparison operators 4<=5 True |
greater than or equal to | Comparison operators 5>=6 False |
unary | applies to a single expression EX 3 != 4 |
binary | Applies to 2 expressions EX 3>5 or 6+7 == 13 True EX 3>5 and 6+7 == 13 False |
variable names | Can be lowercase, uppercase, the underscore character (_), and, except for the first character, digits 0 through 9. 1. should be meaningful, and brief 2. multiple-word name: underscore or CamelCase 3. reserved words |
Reserved words Booleans (5) | 1. True 2. False 3. None (no value, can't decide T or F) 4. and 5. or 6. not |
Reserved Words writing Loops (7) | 1. def (define) 2. if 3. else ( this else that) 4. elif (this, or that, or that, or...) 5. for 6. in 7. while |
Reserved Words for seeing results or getting data (2) | 1. return 2. yield |
Reserved Words for Variable definition and location (3) | 1. import 2. from 3. lambda 4. class 5. is (is None) 6. global 7. nonlocal |
lambda | always 'return' statement go anywhere a function is expected def make_incrementor (n): return lambda x: x + n f = make_incrementor(2) g = make_incrementor(6) print f(42), g(42) 44 48 http://www.secnetix.de/olli/Python/lambda_functions.hawk |
Rerserved Words DeBugging (5) | 1. try 2. except 3. assert 4. finally 5. raise 6. with 7. as |
Exceptions definition | when Python can't deal with script occurs during execution disrupts program's instructions. must handle the exception immediately otherwise will terminate and come out. http://www.tutorialspoint.com/python/python_exceptions.htm |
Exception Example | try: You do your operations here except ExceptionI: execute this block except ExceptionII: execute this block else: no exception, then execute this block |
pass | does nothing can be a place holder It can be used when a statement is required syntactically but the program requires no action. commonly used for creating minimal classes null set |
assert | assert Expression[, Arguments] If false, AssertionError exception. Handled like any other exception using the try-except statement, or terminates the program and produces error http://www.tutorialspoint.com/python/assertions_in_python.htm |
finally | place to put any code that must execute, regardless of previous errors |
break | stops at the first value in range that fulfills statement stops a (for) or (while) Loop, kind of control, stops the smallest tier, doesn't go into else http://docs.python.org/release/1.5/tut/node23.html |
Reserved Words control | 1. break 2. continue 3. pass 4. del |
continue | go to next value in range to test |
raise | flags error/exception to be checked later |
class | a group of objects that have the same functions |
with | simplifies exception handling encapsulates common preparation cleans up tasks in so-called context managers. This allows common try-except-finally usage patterns to be encapsulated for convenient reuse. |
yield | doesn't return a list, this returns an iterator So if you need the primes one at a time, in order, perhaps to call a function on each one, an iterator might be good. |
from | Import names from a module. like math |
global | defined outside function, access throughout program |
local | defined inside function body, accessed only inside declared function, not reserved |
del | dict = {'Name': 'Zara', 'Class': 'First'}; del dict['Name']; # remove entry with key 'Name' dict.clear(); # remove all entries in dict del dict ; # delete entire dictionary |
Created by:
kbaldwin
Popular Computers sets