Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views2 pages

Programmih Finale

The document outlines various programming concepts including arithmetic operations, boolean logic, control structures, and file handling in Python. It covers topics such as function definitions, mutable vs immutable types, and data structures like lists and dictionaries. Additionally, it discusses the importance of pseudocode for outlining programs and the use of methods for modifying data.

Uploaded by

jeffrey.j.ke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Programmih Finale

The document outlines various programming concepts including arithmetic operations, boolean logic, control structures, and file handling in Python. It covers topics such as function definitions, mutable vs immutable types, and data structures like lists and dictionaries. Additionally, it discusses the importance of pseudocode for outlining programs and the use of methods for modifying data.

Uploaded by

jeffrey.j.ke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

T2: ⛒ (pitfalls) ( “3” + 4) or (“str” * float)​

Arithmetic: Unary -, +; Binary + - * ** // %; 1 ​


or 2 operands; Relational operators: < > == >= !=
Booleans: NOT => AND => OR​
T3: pseudocode, helps form outline.
T4: import math, math.pi; from math import *, pi
T5: If; If True, runs. Elif; Runs only if If => False. (if another If, both run) Else; If all is false ​
While; repeat until condition is met, you can use While True and break for infinite loops.
T6: Index starts at 0,Slicing: Start(included), end(excluded) and opt. Step value. [0:4:2] ​
Concatenation; “a” + “b” = “ab”, [1] + [2] = [1, 2], 4 * [0] = [0, 0, 0, 0].
T7: Booleans; Empty collections are False, with contents is True. (don't compare with true/false)
Short circuit evaluation; evaluates right-hand side of boolean expression only if needed (might not get error even if code is faulty).
T8: for - Used with range() and len(), [start, end-1, step], can be indexed. Name assigned to each value of expression.
T9: Defining Functions; Decomposes large programs into smaller pieces. What happens in a function stays in the function.
​ If names are local to the function, you can use those names outside and they will not be affected. (aka. reusable)
Return; exits function body. Defines value of function call. Return expression of any type. None is returned if omitted or no statement.
​ Multiple returns “can” be used but early returns have to be indented, and the final return will be the result.
T10: Methods; Immutable values change only through assignment. Mutable types can with functions or methods&ass (modify by index).​
​ Strings​ ​ ​ ​ Lists​ ​ ​ ​ Strings​ ​ ​ Collections​ ​

(.isalnum()) = True if alphanumeric.


T11: ‘file_your_in/file_within/file_specific’​
Accessing Files; open() has an optional mode parameter =>
‘w’ deletes existing data. Adding ‘b’ causes binary access, Python returns bytes() values instead of str().
close(); indicated no longer needing access to a file. Return None.
read(); reads char or bytes starting at current file location. Without argument, reads the rest of the file.​ ​
​ Returns a str() or bytes() value
Width: </>/#, Precision: =>
T12: Sequence: list, range, or str, Dict: mutable iterable. Keys and Values.​
​ Item, container[item], “in” command only works for keys.

You might also like