diff options
Diffstat (limited to 'Technology/6.0001 Introduction to Computer Science and Programming in Python.md')
| -rw-r--r-- | Technology/6.0001 Introduction to Computer Science and Programming in Python.md | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/Technology/6.0001 Introduction to Computer Science and Programming in Python.md b/Technology/6.0001 Introduction to Computer Science and Programming in Python.md index 2521eaf..d327cc0 100644 --- a/Technology/6.0001 Introduction to Computer Science and Programming in Python.md +++ b/Technology/6.0001 Introduction to Computer Science and Programming in Python.md @@ -54,7 +54,7 @@ Sementics - Prog langs: only one meaning Everything in Python is an object: -- Scalar(int,float,bool(true/false),None) +- Scalar(int,float,bool(true/false),None,str) - non-scalar(type()) <expr> = <var> @@ -63,3 +63,88 @@ x % y = Remainder when x/y x ** y = x to power of y # Lecture 2 - Branching and Iteration + +== vs = comparaison vs assignement + +a variable is just a name, object can be assigned to more than 1 var +can assign multiples var in one line <><>=<><> + +Operators can be combined to form expressions, the value of the expression is an object of some type() + +## Arithmetic Operators +- + : Addition +- - : Subtraction +- * : Multiplication +- / : Division +- % : Modulo (remainder) +- ** : Exponent +- // : Floor division + +## Comparaison Operators - Compare 2 value and return true or false +- == : Equal to +- != : Nor equal to +- > : Greater than +- < : Less than +- >= : Greater than or equal to +- <= : Lesser than or equal to + +## Assignement Operators - Assign value to var +- = : Assignement +- += : Addition assignement +- -= : Substraction assignement +- *= : Multiplication assignement* +- /= : Division assignement +- %= : Modulo assignement +- //= : Floor division assignement +- **= : Exponentiation assignement** + +## Logical Operators - To combine conditional statements +- AND +- OR +- NOT + +## Bitwise Operator - Operate on Binary numbers +## Membership Operator - Check if value is part of sequence +- in +- not in +## Identity Operator - Check if 2 object refer to the same memory location +- is +- is not + + Variables can't start with a number + Variables are case sensitive + Keywords(reserved words) can't be used + Identatation sementically meaningfull + + Strait Line Programs VS Branching Programs (ex: with conditional expresion) + + + slicing = sequence[start:stop:step] + 'abc'[:] = 'abc'[0:len('abc')] + +when convert float to int : truncated not rounded + +fstring - to format strings + +f"Hello {name}, you are {age} yrs old" +can include any expression in bracket +f"The area of a circle with radius {sum(radius)} is {math.pi * radius}" + +## Conditional Statement +- if : execute if true +- if, elif, else + +## Looping Statement +- for - Iterate over a sequence +- while - Repeat a block of code as long as condition is true + +# Control statement +- break - exit current loop +- continue - skip rest of current iteration and follow to the next iteration in loop +- pass - null does nothing + +range(start,stop,increment) + +PEP8 - https://peps.python.org/pep-0008/ + +# Lecture 3 - String Manipulation, Guess and Check, Approximations, Bisection |
