Basics of Python - I

Basics of Python - I

Outline Introduction Data Types Operators and Expressions Control Flow Problems Computing Laboratory Basics of Python - I Malay Bhattacharyya Assistant Professor Machine Intelligence Unit Indian Statistical Institute, Kolkata December, 2020 Malay Bhattacharyya Computing Laboratory Outline Introduction Data Types Operators and Expressions Control Flow Problems 1 Introduction 2 Data Types 3 Operators and Expressions 4 Control Flow 5 Problems Malay Bhattacharyya Computing Laboratory Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Malay Bhattacharyya Computing Laboratory Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Malay Bhattacharyya Computing Laboratory Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Malay Bhattacharyya Computing Laboratory Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Malay Bhattacharyya Computing Laboratory Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Malay Bhattacharyya Computing Laboratory Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Malay Bhattacharyya Computing Laboratory Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Malay Bhattacharyya Computing Laboratory Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Malay Bhattacharyya Computing Laboratory Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Malay Bhattacharyya Computing Laboratory Outline Introduction Data Types Operators and Expressions Control Flow Problems Basic characteristics Python is a free and open source language, first written in C. Python is an interpreted language. Python is not a free-form language. Python is a strongly typed language. Python is an object-oriented language but it also supports procedural oriented programming. Python is a high level language. Python is a portable and cross-platform language. Python is an extensible language. Note: The reference implementation CPython is now available on GitHub (see: https://github.com/python/cpython). This is no more updated. Malay Bhattacharyya Computing Laboratory Looking into the source code: import inspect inspect.getfullargspec(<built-in function>) inspect.getsource(<live object>) Note: The official Python source releases are available at: https://www.python.org/downloads/source. Outline Introduction Data Types Operators and Expressions Control Flow Problems Knowing Python in a better way Looking into the help manual: help(<built-in object>) help(<built-in function>) Malay Bhattacharyya Computing Laboratory Note: The official Python source releases are available at: https://www.python.org/downloads/source. Outline Introduction Data Types Operators and Expressions Control Flow Problems Knowing Python in a better way Looking into the help manual: help(<built-in object>) help(<built-in function>) Looking into the source code: import inspect inspect.getfullargspec(<built-in function>) inspect.getsource(<live object>) Malay Bhattacharyya Computing Laboratory Outline Introduction Data Types Operators and Expressions Control Flow Problems Knowing Python in a better way Looking into the help manual: help(<built-in object>) help(<built-in function>) Looking into the source code: import inspect inspect.getfullargspec(<built-in function>) inspect.getsource(<live object>) Note: The official Python source releases are available at: https://www.python.org/downloads/source. Malay Bhattacharyya Computing Laboratory Outline Introduction Data Types Operators and Expressions Control Flow Problems The data types in Python Malay Bhattacharyya Computing Laboratory Output: fun Splitting a string: str = "I don't love Python, the snake." print(str.split(" "), str.split(", ")) Output: ['I', "don't", 'love', 'Python,', 'the', 'snake.'] ["I don't love Python", 'the snake.'] Outline Introduction Data Types Operators and Expressions Control Flow Problems Strings Substring of a string: str = "malfunctioning" # Indexing starts with 0 print(str[3:6]) # Elements indexed 3 through 5 Malay Bhattacharyya Computing Laboratory Splitting a string: str = "I don't love Python, the snake." print(str.split(" "), str.split(", ")) Output: ['I', "don't", 'love', 'Python,', 'the', 'snake.'] ["I don't love Python", 'the snake.'] Outline Introduction Data Types Operators and Expressions Control Flow Problems Strings Substring of a string: str = "malfunctioning" # Indexing starts with 0 print(str[3:6]) # Elements indexed 3 through 5 Output: fun Malay Bhattacharyya Computing Laboratory Output: ['I', "don't", 'love', 'Python,', 'the', 'snake.'] ["I don't love Python", 'the snake.'] Outline Introduction

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    74 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us