Welcome to Advanced Python Programming An online certification













![Expressions in Python Examples “hello” [number for number in range(10)]- List average = sum Expressions in Python Examples “hello” [number for number in range(10)]- List average = sum](https://slidetodoc.com/presentation_image/3a2dec96f814ec1b468babcc97574a13/image-14.jpg)





- Slides: 19
Welcome to Advanced Python Programming An online certification course
Course Contents 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. Introduction The Programming Cycle for Python Getting Started Variables and simple data types Elements of python Type conversion Expressions Assignment statement Arithmetic operators Operator precedence Boolean expression Introducing lists Working with lists For loop Nested loops Tuples Unpacking sequences Lists Mutable sequences List comprehension Sets If statements 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. Conditionals (continued) Expression evaluation Float representation Dictionaries User input and loops Break and continue Function Parts of a function Execution of a function Keyword and default arguments Scope rules Strings Indexing and slicing of strings More slicing Higher order functions Sieve of Eratosthenes Abstract data types Classes Modules Importing modules Classes 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. Special methods Class example Inheritance and OOPS Files and exceptions File I/O Exceptions Testing your code Assertions Iterators Recursion Simple search Estimating search time Binary search Estimating Binary search time Recursive Fibonacci Tower of Hanoi Sorting Selection sort Merge list Merge sort Higher order sort
Introduction What is Python? It is a general purpose, high-level, and interpreted programming language Python Features It is simple and easy. It is a general purpose, high-level, interpreted programming language. It supports Cross platforms. It is Free and Open Source. It has huge community and large ecosystem of Libraries, frameworks, and tools. It supports both Object Oriented and Procedure Oriented programming.
Introduction Where do we use Python? Used to develop Windows Applications Used to develop Web Applications Used to develop Mobile Applications Used in the field of AI, ML, and Data Science Used in Hacking Used in Testing and Game development Python History
The Programming Cycle for Python Start Application No compile or link steps Test the behaviour Python programs simply import modules at runtime and use the objects they contain. Because of this, Python programs run immediately after changes are made. Stop Application Edit the Code
Getting Started Setting-up the Environment Install Python - https: //www. python. org/downloads/ Install IDE - Py. Charm - https: //www. jetbrains. com/pycharm/ - Jupyter - https: //jupyter. org/install. html - Spyder - https: //github. com/spyder-ide/spyder - Atom - https: //atom. io/ - Thonny - https: //thonny. org/
Variables and Simple Data types What is variable? Syntax It is a data holder variable. Name = data. Value Naming Rules A variable name must start with a letter or the underscore character, but not with number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0 -9, and _ ) A variable name does not contain any special symbol except underscore( _ ). A variable name should not be a keyword. Variable names are case-sensitive.
Variables and Simple Data types in Python None Numeric – int, float, complex, and bool String List Tuple Set Range Dictionary
Elements of Python What is element? Element is defined as an individual part of Python program. Elements of Python Keywords – Reserved words with specific meaning Identifiers – User specified names Literals – Data values like string, numbers, collections Operators – Symbols used to perform arithmetic and logical operations.
Elements of Python Operators Arithmetic Operators → +, -, *, /, **, // Assignment Operators → =, +=, -=, *=, /=, **=, //= Comparison Operators → <, <=, >, >=, ==, != Logical Operators → and, or, not Bitwise Operators → &, |, ^, ~, <<, >> Identity Operators → is, is not Membership Operators → in, not in
Type Conversion in Python What is type conversion? The process of converting data value from one data type to another Built-in functions for type conversion int(variable) – Converts any value to decimal integer int(variable, base) – Converts any value to integer of specified base float(variable) – Converts any value to float str(variable) – Converts any value to string
Type Conversion in Python What is type conversion? The process of converting data value from one data type to another Built-in functions for type conversion ord(variable) – Converts character value to integer hex(variable) – Converts an integer value to hexadecimal value oct(variable) – Converts an integer value to octal value bin(variable) – Converts an integer value to binary value chr(variable) – Converts a number to corresponding ASCII value
Expressions in Python What is expression? An expression is a set of operators and operands that represent a value Expressions are representations of value Operator Operand = identifier + Literals and is not <<
Expressions in Python Examples “hello” [number for number in range(10)]- List average = sum / count - Dictionary {key : key*10 for key in range(5)} num_1 < num_2 list(value for value in range(10))- Generator 20 == 25 value_1 if True else value_2 - Conditional a < b and a < c
Assignment Statement in Python What is assignment statement? The assignment statement used to assign a value to a variable = Syntax variable. Name = value variable. Name = another. Variable. Name variable. Name = expression
Arithmetic Operators in Python The operator used to perform arithmetic operations + * / % Addition | Concatenation Subtraction Multiplication | String repeater Division Remainder ** // Exponent Floor Division
Operator Precedence in Python What is operator precedence? Operator precedence decides the order of operators to be evaluated in an expression Precedence Operator 1 () [] {} 2 Subscription, slicing, call, attribute 3 ** 4 +x, -x, ~x 5 *, /, //, % 6 +, - 7 <<, >> 8 & 9 ^ 10 | 11 in, not in, is not, <, <=, >, >=, !=, == 12 not x 13 and 14 Or
Boolean expression in Python What is Boolean expression? An expression that evaluates to True or False How Boolean expressions are build? Using Boolean value directly Using Comparison operators Using Logical operators Using Identity operators Using Membership operators bool(value)
Boolean expression in Python What is True? What is False? A boolean value True A boolean value False An expression evaluated to True An expression evaluated to False A non-empty String An empty String A non-zero number A number zero Any non-empty list, tuple, set, dictionary Any empty list, tuple, set, dictionary Value None