Business of Insights Data Science Analytics Foundation Topic

Business of Insights ! Data Science & Analytics Foundation

Topic B : Python for Data Science Module 1: Getting Starting Python Language and Context Tools for Development IDE / Pycharm Quick View Jupyter Notebook Module 2: Language, Libraries Language, Numbers and Operators Data Types, Controls Special Built-in Objects Functions & Modules Module 3: Data Analysis Numpy Pandas Data. Frames Plotting & Visualisation Data Aggregations

Module 1 : Python - Getting Started # Topics A Language, Numbers and Operators B Strings and Control Statements C Special Built-in Objects D Functions & Modules

NOTE : Approach to Learning of this lecture • In this module we will start learning about Python language elements by Hands-on coding. • In the video, I will give explanations as we “learn by doing”. So use the slides more for check list but primarily learn by trying you Python Development environment. • Open your python (Notebook or IDE) environment Follow the video Try the code examples yourself to get the practice and learning Try additional variations using your creativity • Language tokens (like keywords, operators) marked in ‘Yellow’ in rest of the slides

Python Language and Context : Dipping your Toe ! # A Language Elements Hello World! Details Project, Code, Template, Comments print() Strings, additions B C D Quotes Single, Double Triple Quotes (when sentence spans multiple lines) Escape characters \, ’, ”, n (newline), b (backspace), t (tab), r (CR) Execute Code Run (full code) Run Selection (portion of the code) Console (interpreter window – output and interactive working) Breakpoints and Debug F Block of code Represented through indentation

Literals / Data types Python offers three types of numbers with which we can work: Integer, floating point and Imaginary. # A B Language Elements Details Integers • • • There was difference between integer (+/- 2, 147, 483, 648) and long but that has changed Whole number (Positive or Negative) E. g. 10, 100 Floats • • • Numbers that have a fractional component (fraction of 1) e. g. 1. 01, 2. 55 etc. Represents double precision floating point numbers (15 digits precision) Example : Useful when dealing with Finance, Quantities etc. • Note: For Very High-precision (very large or very small numbers) floating point numbers, there are specific modules that could be leveraged. Square root of -1, behaves like float but cannot be mixed with float. e. g. 15 j Specific use for like scientific community. Complex numbers (e. g. 15 j + 20) C Imaginary • • • D Strings • • Sequence of pure unique code characters. Example “abc”, “$%”, “? ? ? ” Each character can be indexed E Boolean values • • True, False Bitwise (<<, >>) F Special Literal • None Ø type() : to check class of a number…

Operators and Manipulations # A B C Language Elements Operators Format Specifiers Evaluation Expressions Details • • Tokens that trigger a computation or calculation or action on variables or objects. Arithmetic Operators : +, -, *, /, %, ** (raised to), // (remainder e. g 5//2 = 2) • • Example : + operator to manipulate two things of same type (e. g. two numbers) Example : “hello” * 3 will give “hellohello”. Exception being Float + Integers. Str can be used for combining numbers and strings (if you don’t want to use +) Example : What happens when you do “Hello world” + 4 ? • • Dividing two integers may result in float. Dividing integer by float will always result in float. • • Modulus (Remainder) : % Example can I evenly divided an array? • • • %d %f For controlling number of decimals e. g. %0. 02 f %E (large number with E or exponential) Escaping % with “%%” %x : Hexadecimal (Base 16), %o for octal (Base 8). • • Multiplication and Division happen before Addition and Subtraction Even then could be confusing. So use parenthesis for explicitly calling priority • • Logical Expressions: (p > q) and (q < y) Arithmetic Operator has higher preference than logical operators.

Variables # A Language Elements Variables Details Give names to data (ideally meaningful names) so that they be referred to later in code. • It is difficult to keep writing strings and numbers explicitly through program. Also you want to generalise of processing steps. • Example mark to hold mark of a student. • • E. g mark = 10 or student_name = “John” Multiple assignments example : x, y, z = 10, 20, 30 Swap values e. g. x, y = y, x Try…print(mark). . • • Variable names to consist of Letters, Numbers and Underscore. Variable names cannot begin with numbers e. g. 15 CLK is not okay. • • Python is case sensitive Python uses Dynamic-Typing B Assignments Examples: • Mark = 100 • mark = mark + 10 Two variables can refer to same data • flower = “rose”; red_flower = flower; C Reserved Words • • D Conversions Numbers to Strings ( str( ) ), String to Numbers ( int( ) or float( ) ) Set of words cannot be used as variables since Python uses them internal work. Example : and, as, break, del, lamda, global, import, exec, except, continue….

Thank you ! www. Business. Of. Insights. com Insights Community Sharing Blogs Perspectives Formal Learning (Courses) Latest Happenings Balaji S. Thiruvenkatachari stbalaji@business. Of. Insights. com 9840768200 AI for Good Giving back
- Slides: 9