This document provides information about the Python programming language. It discusses that Python was invented in the 1990s in the Netherlands by Guido van Rossum and was named after Monty Python. It is an open source, general-purpose, interpreted programming language that is widely used. The document then covers various Python implementations, popular Python editors and IDEs, tips for getting started with Python, basic syntax, data types, operators, and lists.
This document provides an introduction to the Python language and discusses Python data types. It covers how to install Python, interact with the Python interpreter through command line and IDLE modes, and learn basic Python parts like data types, operators, functions, and control structures. The document discusses numeric, string, and other data types in Python and how to manipulate them using built-in functions and operators. It also introduces Python library modules and the arcpy package for geoprocessing in ArcGIS.
Python quickstart for programmers: Python Kung Fuclimatewarrior
The document provides an overview of key Python concepts including data types, operators, control flow statements, functions, objects and classes. It discusses lists in depth, covering creation, iteration, searching and common list methods. It also briefly touches on modules, exceptions, inheritance and other advanced topics.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
This document provides an introduction to Python programming using PyCharm. It discusses downloading and installing Python and PyCharm, creating and running simple Python scripts that use print statements and variables, taking user input, and introducing conditional logic using if/else statements and while loops. Examples include printing ASCII art, basic math operations, and building a text-based choose your own adventure game. Further exercises are suggested to improve the game by adding dice rolls and more options.
Introduction to the Python programming language (version 2.x)
Ambient intelligence: technology and design
http://bit.ly/polito-ami
Politecnico di Torino, 2015
Python 101++: Let's Get Down to Business!Paige Bailey
You've started the Codecademy and Coursera courses; you've thumbed through Zed Shaw's "Learn Python the Hard Way"; and now you're itching to see what Python can help you do. This is the workshop for you!
Here's the breakdown: we're going to be taking you on a whirlwind tour of Python's capabilities. By the end of the workshop, you should be able to easily follow any of the widely available Python courses on the internet, and have a grasp on some of the more complex aspects of the language.
Please don't forget to bring your personal laptop!
Audience: This course is aimed at those who already have some basic programming experience, either in Python or in another high level programming language (such as C/C++, Fortran, Java, Ruby, Perl, or Visual Basic). If you're an absolute beginner -- new to Python, and new to programming in general -- make sure to check out the "Python 101" workshop!
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
1. Python can be used to automate repetitive tasks like data entry, file processing, report generation etc. This saves time and reduces human errors.
2. Python has many libraries for machine learning, data analysis and visualization which can be used to analyze patent data, identify trends, cluster similar technologies etc.
3. Web scraping and web development frameworks like Django can be used to build internal tools and dashboards to manage workflows more efficiently.
4. Python scripts can be written to extract and process data from various sources, perform calculations, format reports in a standardized way reducing manual efforts.
This document provides an introduction to the Python language and discusses Python data types. It covers how to install Python, interact with the Python interpreter through command line and IDLE modes, and learn basic Python parts like data types, operators, functions, and control structures. The document discusses numeric, string, and other data types in Python and how to manipulate them using built-in functions and operators. It also introduces Python library modules and the arcpy package for geoprocessing in ArcGIS.
Python quickstart for programmers: Python Kung Fuclimatewarrior
The document provides an overview of key Python concepts including data types, operators, control flow statements, functions, objects and classes. It discusses lists in depth, covering creation, iteration, searching and common list methods. It also briefly touches on modules, exceptions, inheritance and other advanced topics.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
This document provides an introduction to Python programming using PyCharm. It discusses downloading and installing Python and PyCharm, creating and running simple Python scripts that use print statements and variables, taking user input, and introducing conditional logic using if/else statements and while loops. Examples include printing ASCII art, basic math operations, and building a text-based choose your own adventure game. Further exercises are suggested to improve the game by adding dice rolls and more options.
Introduction to the Python programming language (version 2.x)
Ambient intelligence: technology and design
http://bit.ly/polito-ami
Politecnico di Torino, 2015
Python 101++: Let's Get Down to Business!Paige Bailey
You've started the Codecademy and Coursera courses; you've thumbed through Zed Shaw's "Learn Python the Hard Way"; and now you're itching to see what Python can help you do. This is the workshop for you!
Here's the breakdown: we're going to be taking you on a whirlwind tour of Python's capabilities. By the end of the workshop, you should be able to easily follow any of the widely available Python courses on the internet, and have a grasp on some of the more complex aspects of the language.
Please don't forget to bring your personal laptop!
Audience: This course is aimed at those who already have some basic programming experience, either in Python or in another high level programming language (such as C/C++, Fortran, Java, Ruby, Perl, or Visual Basic). If you're an absolute beginner -- new to Python, and new to programming in general -- make sure to check out the "Python 101" workshop!
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
1. Python can be used to automate repetitive tasks like data entry, file processing, report generation etc. This saves time and reduces human errors.
2. Python has many libraries for machine learning, data analysis and visualization which can be used to analyze patent data, identify trends, cluster similar technologies etc.
3. Web scraping and web development frameworks like Django can be used to build internal tools and dashboards to manage workflows more efficiently.
4. Python scripts can be written to extract and process data from various sources, perform calculations, format reports in a standardized way reducing manual efforts.
The document discusses dictionaries in Python. It explains that dictionaries are a mapping type that store key-value pairs, with keys being immutable types and values being any type. It provides examples of creating, accessing, updating, removing entries from, and accessing properties of dictionaries. It also covers functions, control flow statements like if/else and while loops, and list comprehensions.
Introduction to the basics of Python programming (part 3)Pedro Rodrigues
This is the 3rd part of a multi-part series that teaches the basics of Python programming. It covers list and dict comprehensions, functions, modules and packages.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
- Variables in PHP are prefixed with a $ sign and can contain any type of data value. Variable names are case-sensitive.
- PHP supports scalar data types like integers, floats, booleans, and strings as well as complex types like arrays and objects. Variables do not require explicit typing.
- Arrays allow storing multiple values in a single variable through numeric or associative indexes. Arrays can be nested to any level and PHP provides many functions for manipulating array values and structure.
This document provides an introduction to the Python programming language. It covers Python's background, syntax, types, operators, control flow, functions, classes, tools, and IDEs. Key points include that Python is a multi-purpose, object-oriented language that is interpreted, strongly and dynamically typed. It focuses on readability and has a huge library of modules. Popular Python IDEs include Emacs, Vim, Komodo, PyCharm, and Eclipse.
Python is a high-level, interpreted programming language that is designed to be easy to read and write. It has a clear syntax using English keywords and its code is often shorter than languages like C++ and Java. Python is widely used for web development, software development, science, and machine learning. It has a large standard library and can be extended through modules. Some key data structures in Python include lists, tuples, and dictionaries.
This document provides information on Python code structures, including if/else statements, loops (while and for), functions, and arguments. It explains the basic syntax and usage of these structures. Key points covered include:
- How to write if/else statements and the use of conditions like ==, !=, <, >, etc.
- The syntax of while and for loops, and how to use break, continue, else blocks
- What functions are in Python and how to define them with def, pass arguments, and return values
- The basics of calling functions, optional arguments, and nested structures like if/else in loops
This document provides an overview and instructions for a course in Python programming. It discusses the recommended course literature, including Learning Python and Python in a Nutshell books. It also describes using the IDLE integrated development environment for writing and running Python code on Windows and Unix systems. The document then begins covering basic Python concepts like variables, data types, strings, lists, dictionaries and objects.
This document provides an introduction to Python programming concepts such as variables, data types, strings, lists, dictionaries, conditionals, loops, functions and modules. It covers Python basics like formatting, naming conventions and comments. Key concepts are explained through examples, such as how to define and modify variables and different data structures, perform string operations, take user input, and define reusable functions. The document is intended to teach Python fundamentals to new programmers.
Python, the Language of Science and Engineering for EngineersBoey Pak Cheong
A talk given in November 2016 at IEM Malaysia to engineers, who are new to Python, a broad perspective of what Python is, why it is important to learn it and how it can help in solving/visualization of engineering and scientific tasks and problems.
DNA contains all of an organism's genetic information and is found in the cells of all living things. DNA is made up of long chains of nucleotides, which consist of a sugar, phosphate, and one of four nitrogen-containing bases. The order of these bases in the DNA determines an organism's traits by encoding genes. James Watson and Francis Crick discovered that DNA exists as a double helix structure, with the bases pairing together in a complementary way between chains.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
This document is a project report submitted by Team NoFrazzle for their Tricky Math Puzzle game built using Assembly language. The game has three segments - a math teaser segment with tricky math questions, a sequence guessing segment, and an assumption skill segment where the player guesses 3 random numbers. It uses Assembly instructions like loops, conditions, procedures. The interface is described along with the work flow and the use of instructions like CMP, JMP, CALL and INTs. Future plans include improving the graphics, adding AI features, more segments and stages to the game.
Protein synthesis involves DNA being transcribed into mRNA which is then translated into proteins with the help of tRNA and rRNA. There are three main types of RNA - mRNA carries the genetic code from DNA to ribosomes, tRNA carries amino acids and bonds to mRNA through anticodons, and rRNA makes up ribosomes where protein synthesis occurs. The sequence of codons in mRNA determines the specific amino acid sequence of the resulting protein.
The document discusses dictionaries in Python. It explains that dictionaries are a mapping type that store key-value pairs, with keys being immutable types and values being any type. It provides examples of creating, accessing, updating, removing entries from, and accessing properties of dictionaries. It also covers functions, control flow statements like if/else and while loops, and list comprehensions.
Introduction to the basics of Python programming (part 3)Pedro Rodrigues
This is the 3rd part of a multi-part series that teaches the basics of Python programming. It covers list and dict comprehensions, functions, modules and packages.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
- Variables in PHP are prefixed with a $ sign and can contain any type of data value. Variable names are case-sensitive.
- PHP supports scalar data types like integers, floats, booleans, and strings as well as complex types like arrays and objects. Variables do not require explicit typing.
- Arrays allow storing multiple values in a single variable through numeric or associative indexes. Arrays can be nested to any level and PHP provides many functions for manipulating array values and structure.
This document provides an introduction to the Python programming language. It covers Python's background, syntax, types, operators, control flow, functions, classes, tools, and IDEs. Key points include that Python is a multi-purpose, object-oriented language that is interpreted, strongly and dynamically typed. It focuses on readability and has a huge library of modules. Popular Python IDEs include Emacs, Vim, Komodo, PyCharm, and Eclipse.
Python is a high-level, interpreted programming language that is designed to be easy to read and write. It has a clear syntax using English keywords and its code is often shorter than languages like C++ and Java. Python is widely used for web development, software development, science, and machine learning. It has a large standard library and can be extended through modules. Some key data structures in Python include lists, tuples, and dictionaries.
This document provides information on Python code structures, including if/else statements, loops (while and for), functions, and arguments. It explains the basic syntax and usage of these structures. Key points covered include:
- How to write if/else statements and the use of conditions like ==, !=, <, >, etc.
- The syntax of while and for loops, and how to use break, continue, else blocks
- What functions are in Python and how to define them with def, pass arguments, and return values
- The basics of calling functions, optional arguments, and nested structures like if/else in loops
This document provides an overview and instructions for a course in Python programming. It discusses the recommended course literature, including Learning Python and Python in a Nutshell books. It also describes using the IDLE integrated development environment for writing and running Python code on Windows and Unix systems. The document then begins covering basic Python concepts like variables, data types, strings, lists, dictionaries and objects.
This document provides an introduction to Python programming concepts such as variables, data types, strings, lists, dictionaries, conditionals, loops, functions and modules. It covers Python basics like formatting, naming conventions and comments. Key concepts are explained through examples, such as how to define and modify variables and different data structures, perform string operations, take user input, and define reusable functions. The document is intended to teach Python fundamentals to new programmers.
Python, the Language of Science and Engineering for EngineersBoey Pak Cheong
A talk given in November 2016 at IEM Malaysia to engineers, who are new to Python, a broad perspective of what Python is, why it is important to learn it and how it can help in solving/visualization of engineering and scientific tasks and problems.
DNA contains all of an organism's genetic information and is found in the cells of all living things. DNA is made up of long chains of nucleotides, which consist of a sugar, phosphate, and one of four nitrogen-containing bases. The order of these bases in the DNA determines an organism's traits by encoding genes. James Watson and Francis Crick discovered that DNA exists as a double helix structure, with the bases pairing together in a complementary way between chains.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
This document is a project report submitted by Team NoFrazzle for their Tricky Math Puzzle game built using Assembly language. The game has three segments - a math teaser segment with tricky math questions, a sequence guessing segment, and an assumption skill segment where the player guesses 3 random numbers. It uses Assembly instructions like loops, conditions, procedures. The interface is described along with the work flow and the use of instructions like CMP, JMP, CALL and INTs. Future plans include improving the graphics, adding AI features, more segments and stages to the game.
Protein synthesis involves DNA being transcribed into mRNA which is then translated into proteins with the help of tRNA and rRNA. There are three main types of RNA - mRNA carries the genetic code from DNA to ribosomes, tRNA carries amino acids and bonds to mRNA through anticodons, and rRNA makes up ribosomes where protein synthesis occurs. The sequence of codons in mRNA determines the specific amino acid sequence of the resulting protein.
The document discusses object-oriented programming concepts in Python including classes, objects, methods, encapsulation, inheritance, and polymorphism. It provides examples of defining a class with attributes and methods, instantiating objects from a class, and accessing object attributes and methods. It also covers the differences between procedure-oriented and object-oriented programming, and fundamental OOP concepts like encapsulation, inheritance, and polymorphism in Python.
Python was created in the late 1980s by Guido van Rossum and first released in 1991. It gained popularity and saw new releases in 2000 and 2008. Python is an open source, general purpose, interpreted, object-oriented programming language used widely for web development, science, and more due to its large community and support. Performance depends more on frameworks and architecture than language alone.
This document discusses brachytherapy, a type of radiation therapy where radioactive material is placed directly inside the body near the tumor being treated. It begins by explaining the two major categories of radiation therapy: external-beam therapy where a machine emits radiation from outside the body, and brachytherapy where radioactive sources are placed inside the body. It then provides details on brachytherapy, including how it works from inside the body compared to external beam therapy, common radiation sources used, and the typical procedure involving planning, applicator insertion, treatment delivery, and removal of sources.
Python for Data Science - Python Brasil 11 (2015)Gabriel Moreira
This talk demonstrate a complete Data Science process, involving Obtaining, Scrubbing, Exploring, Modeling and Interpreting data using Python ecosystem tools, like IPython Notebook, Pandas, Matplotlib, NumPy, SciPy and Scikit-learn.
NLTK - Natural Language Processing in Pythonshanbady
For full details, including the address, and to RSVP see: http://www.meetup.com/bostonpython/calendar/15547287/ NLTK is the Natural Language Toolkit, an extensive Python library for processing natural language. Shankar Ambady will give us a tour of just a few of its extensive capabilities, including sentence parsing, synonym finding, spam detection, and more. Linguistic expertise is not required, though if you know the difference between a hyponym and a hypernym, you might be able to help the rest of us! Socializing at 6:30, Shankar's presentation at 7:00. See you at the NERD.
This document discusses object-oriented programming concepts in Python including multiple inheritance, method resolution order, method overriding, and static and class methods. It provides examples of multiple inheritance where a class inherits from more than one parent class. It also explains method resolution order which determines the search order for methods and attributes in cases of multiple inheritance. The document demonstrates method overriding where a subclass redefines a method from its parent class. It describes static and class methods in Python, noting how static methods work on class data instead of instance data and can be called through both the class and instances, while class methods always receive the class as the first argument.
Basics of Object Oriented Programming in PythonSujith Kumar
The document discusses key concepts of object-oriented programming (OOP) including classes, objects, methods, encapsulation, inheritance, and polymorphism. It provides examples of classes in Python and explains OOP principles like defining classes with the class keyword, using self to reference object attributes and methods, and inheriting from base classes. The document also describes operator overloading in Python to allow operators to have different meanings based on the object types.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum who named it after the Monty Python comedy troupe. People use Python for a variety of tasks due to its readability, object-oriented capabilities, extensive libraries, and ability to integrate with other languages. To run Python code, it must first be compiled into bytecode which is then interpreted by the Python virtual machine.
Python was developed by Guido van Rossum and named after the BBC show Monty Python's Flying Circus. It is an interpreted, interactive, and object-oriented programming language that allows developers to write code in fewer lines compared to other languages. Python code is highly readable due to its use of indentation instead of brackets and its support for modular programming.
The document discusses elements of developing a business intelligence strategy, including understanding an organization's BI maturity level, aligning metrics and goals across different business units, establishing a Business Intelligence Competency Center, and determining whether to build a BI solution from scratch or purchase pre-built BI applications. It provides an overview of various components that should be considered when creating a comprehensive BI strategy.
This document provides an introduction and overview of the Python programming language. It describes Python as a general-purpose, object-oriented programming language with features like high-level programming capabilities, an easily understandable syntax, portability, and being easy to learn. It then discusses Python's characteristics like being an interpreted language, supporting object-oriented programming, being interactive and easy to use, having straightforward syntax, being portable, extendable, and scalable. The document also outlines some common uses of Python like for creating web and desktop applications, and provides examples of using Python's interactive and script modes.
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
This document provides an overview of basic C# programming concepts. It covers topics such as program structure, data types, variables, operators, decision making statements, loops, classes and methods. Specifically, it discusses if/else statements, switch cases, ternary operators, for, while and do-while loops. It also provides examples of basic C# programs and explanations of concepts like classes, methods, constructors and namespaces.
The document provides an overview of basic Python programming concepts including the structure of a Python program, data types, variables, operators, expressions, statements, functions, modules, and libraries. It discusses Python syntax elements like indentation, keywords, identifiers, literals, and escape sequences. It also covers basic Python programming concepts like input/output, operators, variables, and data types. The document is intended as an introductory guide to the basics of Python programming.
Python tutorials for beginners | IQ Online TrainingRahul Tandale
Python training program walks you through basics of python language and gives you in-depth knowledge of function,collections,REs,Exception Handing,
Socket programming and OOP basics.The course also explains object-oriented as well as functional programming techniques,error handling,packaging system and network programming.The course curriculum is designed for developer,system administrators and QA engineers.
This program also covers many of python extensions(libraries)as well as best practices
The document discusses Python programming language. It provides an overview of what Python is, what it can be used for, and why it is a popular language. Specifically, it notes that Python was created by Guido van Rossum and released in 1991. It is used for web development, software development, mathematics, and system scripting. The document then covers Python syntax, basic data types, operators, decision making and control flow statements like if/else and loops.
The document discusses various operators in Python including arithmetic, comparison, bitwise, logical, and membership operators. It provides examples of using each operator and explains their functionality. The key types of operators covered are arithmetic (e.g. +, -, *, /), comparison (e.g. ==, !=, >, <), bitwise (e.g. &, |, ^), logical (e.g. and, or, not), and membership (e.g. in, not in) operators. It also discusses operator precedence and provides examples of expressions using different operators.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
The document provides an introduction and comparison of Python and C programming languages. Some key points:
- Python is an interpreted language while C needs compilation. Python makes program development faster.
- Variables, input/output, arrays, control structures like if/else, for loops work differently in Python compared to C.
- Python uses lists instead of arrays. Lists are mutable and support slicing.
- Strings are treated as character lists in Python.
- Functions are defined using def keyword in Python.
- The document also introduces sequences (strings, tuples, lists), dictionaries, and sets in Python - their usage and operations.
This document discusses various operators in Java including unary, binary, ternary, relational, logical, and bitwise operators. It explains what operators are, how they are classified based on operands, and provides examples of common unary operators like increment/decrement. It also covers binary arithmetic operators, shorthand expressions, the ternary operator, relational and logical operators. Finally, it discusses bitwise logical operators, operator precedence, and associativity in Java.
The document provides an overview of the C programming language. It discusses that C was developed in 1972 at Bell Labs and the Unix operating system was written in C. It then summarizes some basic elements of C like data types (int, char, float), variables, operators, conditional statements like if-else, loops like for and while loops, and functions. The document gives examples of many common functions in C like printf(), scanf(), getch() etc.
This document provides an overview of the C++ programming language. It discusses that C++ is a statically typed, compiled language that supports procedural and object-oriented programming. C++ was developed in 1979 by Bjarne Stroustrup as an enhancement to C with object-oriented capabilities. The document then covers various C++ concepts like data types, operators, program structure, and differences between C and C++.
This document provides a summary of previous parts of a Python tutorial and introduces several Python concepts including input, iterators, generators, ranges, operators, and control flow. It discusses how to take input in Python, defines iterators and generators, explains the difference between range and xrange, outlines common arithmetic, comparison, assignment, logical, membership, and identity operators, and covers loops, branches, and order of operations in Python. The document is intended to continue guiding the reader through learning Python.
The document provides information about Java programming concepts including:
- How to download, install Java, and write a simple "Hello World" program.
- Common operators in Java like arithmetic, assignment, logical, and comparison operators.
- How to compile and run a Java program from the command line.
- Core Java concepts like variables, data types, classes, and methods.
- The document is intended as an introduction to Java programming for beginners.
C++ provides operators for composing arithmetic, relational, logical, bitwise, and conditional expressions. It also provides operators which produce useful side-effects, such as assignment, increment, and decrement. We will look at each category of operators in turn. We will also discuss the precedence rules which govern the order of operator evaluation in a multi-operator expression.
This document provides a quick tour of the Python programming language. It introduces basic Python concepts like data types, variables, operators, conditional statements, loops, and functions. It explains how to get user input, perform type conversions, and work with common data types like integers, floats, strings, and booleans. It also demonstrates how to define functions, use default arguments and keyword arguments, and handle global variables. The document uses examples to illustrate concepts like arithmetic operations, string slicing, indexing, concatenation, and repetition.
This document provides an introduction to the Python programming language. It discusses Python's design philosophy emphasizing readability. It also covers printing messages, reading input, variables and data types, operators, and basic syntax like comments and identifiers. Arithmetic, relational, logical and bitwise operators are explained along with examples.
Similar to Introduction to Python Language and Data Types (20)
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
How to Fix the Import Error in the Odoo 17Celine George
An import error occurs when a program fails to import a module or library, disrupting its execution. In languages like Python, this issue arises when the specified module cannot be found or accessed, hindering the program's functionality. Resolving import errors is crucial for maintaining smooth software operation and uninterrupted development processes.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Leveraging Generative AI to Drive Nonprofit InnovationTechSoup
In this webinar, participants learned how to utilize Generative AI to streamline operations and elevate member engagement. Amazon Web Service experts provided a customer specific use cases and dived into low/no-code tools that are quick and easy to deploy through Amazon Web Service (AWS.)
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
How to Setup Warehouse & Location in Odoo 17 Inventory
Introduction to Python Language and Data Types
1.
2. Invented in the Netherlands, early 90s by Guido van
Rossum
Named after Monty Python
Open sourced from the beginning
Used by Google from the beginning
80 versions as of 4th
October 2014.
“Python” or “CPython” is written in C/C++
- Version 2.7.7 came out in mid-2010
- Version 3.4.2 came out in late 2014
“Jython” is written in Java for the JVM
“IronPython” is written in C# for the .Net environment
3. “Python is an experiment in how
much freedom programmers need.
Too much freedom and nobody can
read another's code; too little and
expressive-ness is endangered.”
- Guido van Rossum
4. Python is
super easy to learn,
relatively fast,
object-oriented,
strongly typed,
widely used, and
portable.
C is much faster but
much harder to use.
Java is about as fast and
slightly harder to use.
Perl is slower, is as easy
to use, but is not strongly
typed.
R is more of
programming language
for statistics.
7. Great for learning the language
Great for experimenting with the library
Great for testing your own modules
Two variations: IDLE (GUI) (next slide),
python (command line)
Press “Windows + R” and then write “python”. Enter
Type statements or expressions at prompt:
>>> print "Hello, world"
Hello, world
>>> x = 12**2
>>> x/2
72
8. IDLE is an Integrated Development Environment for
Python, typically used on Windows
Multi-window text editor with syntax highlighting, auto-
completion, smart indent and other.
Python shell with syntax highlighting.
Integrated debugger
with stepping, persis-
tent breakpoints,
and call stack visi-
bility
9. Install Python 2.7.7 from the official website. 32 bit as most
packages are built for that.
Install setuptools, which will help to install other packages.
Download the setup tools and then install.
Start the Python IDLE and start programming.
Install Ipython which provides a browser-based notebook with
support for code, text, mathematical expressions, inline plots and
other rich media.
Start writing small programs using problems at
http://www.ling.gu.se/~lager/python_exercises.html
Can also use www.codecademy.com/tracks/python which has an
interactive structure + deal with web APIs.
10. Start comments with #, rest of line is ignored
Can include a “documentation string” as the first line of
a new function or class you define
# My first program
def fact(n):
“““fact(n) assumes n is a positive integer and returns
facorial of n.”””
assert(n>0)
return 1 if n==1 else n*fact(n-1)
11. Names are case sensitive and cannot start with a
number. They can contain letters, numbers, and
underscores.
var Var _var _2_var_ var_2 VaR
2_Var 222var
There are some reserved words:
and, assert, break, class, continue, def, del, elif, else,
except, exec, finally, for, from, global, if, import, in, is,
lambda, not, or, pass, print, raise, return, try, while
12. No need to declare unlike in JAVA
Simple assignment:
▪ a = 2, A = 2
Need to assign (initialize)
▪ use of uninitialized variable raises exception
Not typed
if friendly: greeting = "hello world“ #(or ‘hello word’)
else: greeting = 12**2
print greeting
13. a
1
b
a
1b
a = 1
a = a+1
b = a
a 1
2
old reference deleted
by assignment (a=...)
new int object created
by add operator (1+1)
14. If you try to access a name before it’s been properly created
(by placing it on the left side of an assignment), you’ll get an
error.
>>> y
Traceback (most recent call last):
File "<pyshell#16>", line 1, in -toplevel-
y
NameError: name ‘y' is not defined
>>> y = 3
>>> y
3
15. Assignment manipulates references
▪ x = y does not make a copy of y
▪ x = y makes x reference the object y references
Very useful; but beware!
Example:
>>> a = [1, 2, 3]
>>> b = a
>>> a.append(4)
>>> print b
[1, 2, 3, 4]
16. You can also assign to multiple names at the same time.
>>> x, y = 2, 3
>>> x
2
>>> y
3
>>> x, y, z = 2, 3, 5.67
>>> x
2
>>> y
3
>>> z
5.67
17. + Addition - Adds values on either side of the
operator
a + b will give 30
- Subtraction - Subtracts right hand operand from
left hand operand
a - b will give -10
* Multiplication - Multiplies values on either side of
the operator
a * b will give 200
/ Division - Divides left hand operand by right hand
operand
b / a will give 2
% Modulus - Divides left hand operand by right hand
operand and returns remainder
b % a will give 0
** Exponent - Performs exponential (power)
calculation on operators
a**b will give 10 to the power
20
// Floor Division - The division of operands where the
result is the quotient in which the digits after the
decimal point are removed.
9//2 is equal to 4 and 9.0//2.0
is equal to 4.0
18. == Checks if the value of two operands are equal or not, if
yes then condition becomes true.
(a == b) is not true.
!= Checks if the value of two operands are equal or not, if
values are not equal then condition becomes true.
(a != b) is true.
<> Checks if the value of two operands are equal or not, if
values are not equal then condition becomes true.
(a <> b) is true. This is similar
to != operator.
> Checks if the value of left operand is greater than the
value of right operand, if yes then condition becomes
true.
(a > b) is not true.
< Checks if the value of left operand is less than the value
of right operand, if yes then condition becomes true.
(a < b) is true.
>= Checks if the value of left operand is greater than or
equal to the value of right operand, if yes then condition
becomes true.
(a >= b) is not true.
<= Checks if the value of left operand is less than or equal to
the value of right operand, if yes then condition becomes
true.
(a <= b) is true.
19. & Binary AND Operator copies a bit to the result if it
exists in both operands.
(a & b) will give 12 which is
0000 1100
| Binary OR Operator copies a bit if it exists in eather
operand.
(a | b) will give 61 which is 0011
1101
^ Binary XOR Operator copies the bit if it is set in one
operand but not both.
(a ^ b) will give 49 which is
0011 0001
~ Binary Ones Complement Operator is unary and has
the efect of 'flipping' bits.
(~a ) will give -61 which is 1100
0011 in 2's complement form
due to a signed binary number.
<< Binary Left Shift Operator. The left operands value is
moved left by the number of bits specified by the
right operand.
a << 2 will give 240 which is
1111 0000
>> Binary Right Shift Operator. The left operands value is
moved right by the number of bits specified by the
right operand.
a >> 2 will give 15 which is
0000 1111
20. Operator Description Example
and Called Logical AND operator. If both the
operands are true then then condition
becomes true.
(a and b) is true.
or Called Logical OR Operator. If any of the two
operands are non zero then then condition
becomes true.
(a or b) is true.
not Called Logical NOT Operator. Use to reverses
the logical state of its operand. If a condition
is true then Logical NOT operator will make
false.
not(a and b) is false.
21. in Evaluates to true if it finds a variable in the
specified sequence and false otherwise.
x in y, here in results in a 1 if x
is a member of sequence y.
not in Evaluates to true if it does not finds a
variable in the specified sequence and false
otherwise.
x not in y, here not in results
in a 1 if x is not a member of
sequence y.
is Evaluates to true if the variables on either
side of the operator point to the same object
and false otherwise.
x is y, here is results in 1 if
id(x) equals id(y).
is not Evaluates to false if the variables on either
side of the operator point to the same object
and true otherwise.
x is not y, here is not results
in 1 if id(x) is not equal to
id(y).
22. We use the term object to refer to any entity in a python
program.
Every object has an associated type, which determines the
properties of the object.
Python defines six types of built-in objects:
Number : 10
String : “hello”, ‘hi’
List: [1, 17, 44]
Tuple : (4, 5)
Dictionary: {‘food’ : ‘something you eat’,
‘lobster’ : ‘an edible, undersea arthropod’}
File
Each type of object has its own properties, which we will learn
about in the next several weeks.
Types can be accessed by ‘type’ method
24. Flexible arrays, mutable
▪ a = [99, "bottles of beer", ["on", "the", "wall"]]
Same operators as for strings
▪ a+b, a*3, a[0], a[-1], a[1:], len(a)
Item and slice assignment
▪ a[0] = 98
▪ a[1:2] = ["bottles", "of", "beer"]
-> [98, "bottles", "of", "beer", ["on", "the", "wall"]]
▪ del a[-1] # -> [98, "bottles", "of", "beer"]
[0]*3 = [0,0,0]
25. >>> list_ex = (23, ‘abc’, 4.56, (2,3), ‘def’)
Positive index: count from the left, starting with 0
>>> list_ex[1]
‘abc’
Negative index: count from right, starting with –1
>>> list_ex[-3]
4.56
26. >>> list_ex = (23, ‘abc’, 4.56, (2,3), ‘def’)
Return a copy of the container with a subset of the original
members. Start copying at the first index, and stop copying
before second.
>>> list_ex[1:4]
(‘abc’, 4.56, (2,3))
Negative indices count from end
>>> list_ex[1:-1]
(‘abc’, 4.56, (2,3))
27. >>> list_ex = (23, ‘abc’, 4.56, (2,3), ‘def’)
Omit first index to make copy starting from beginning of
the container
>>> list_ex[:2]
(23, ‘abc’)
Omit second index to make copy starting at first index and
going to end
>>> list_ex[2:]
(4.56, (2,3), ‘def’)
28. [ : ] makes a copy of an entire sequence
>>> list_ex[:]
(23, ‘abc’, 4.56, (2,3), ‘def’)
Note the difference between these two lines for mutable
sequences
>>> l2 = l1 # Both refer to 1 ref,
# changing one affects both
>>> l2 = l1[:] # Independent copies, two refs
29. >>> li = [‘abc’, 23, 4.34, 23]
>>> li[1] = 45
>>> li
[‘abc’, 45, 4.34, 23]
Name li still points to the same memory reference when
we’re done.
30. a
1 2 3
b
a
1 2 3
b
4
a = [1, 2, 3]
a.append(4)
b = a
a 1 2 3
32. + creates a fresh list with a new memory ref
extend operates on list li in place.
>>> li.extend([9, 8, 7])
>>> li
[1, 2, ‘i’, 3, 4, 5, ‘a’, 9, 8, 7]
Potentially confusing:
extend takes a list as an argument.
append takes a singleton as an argument.
>>> li.append([10, 11, 12])
>>> li
[1, 2, ‘i’, 3, 4, 5, ‘a’, 9, 8, 7, [10, 11, 12]]
33. Lists have many methods, including index, count, remove,
reverse, sort
>>> li = [‘a’, ‘b’, ‘c’, ‘b’]
>>> li.index(‘b’) # index of 1st
occurrence
1
>>> li.count(‘b’) # number of occurrences
2
>>> li.remove(‘b’) # remove 1st
occurrence
>>> li
[‘a’, ‘c’, ‘b’]
35. >>> names[0]
‘Ben'
>>> names[1]
‘Chen'
>>> names[2]
‘Yaqin'
>>> names[3]
Traceback (most recent call last):Traceback (most recent call last):
File "<stdin>", line 1, in <module>File "<stdin>", line 1, in <module>
IndexError: list index out of rangeIndexError: list index out of range
>>> names[-1]
‘Yaqin'
>>> names[-2]
‘Chen'
>>> names[-3]
[0] is the first item.
[1] is the second item
...
Out of range values
raise an exception
Negative values
go backwards from
the last element.
Names = [ ‘Ben’, ‘Chen’, ‘Yaqin’]
37. >>> names
['ben', 'chen', 'yaqin']['ben', 'chen', 'yaqin']
>>> gender = [0, 0, 1][0, 0, 1]
>>> zip(names, gender)
[('ben', 0), ('chen', 0), ('yaqin', 1)][('ben', 0), ('chen', 0), ('yaqin', 1)]
Can also be done using a for loop, but this is more efficientCan also be done using a for loop, but this is more efficient
38. The comma is the tuple creation operator, not parentheses
>>> 1, -> (1,)
Python shows parentheses for clarity (best practice)
>>> (1,) -> (1,)
Don't forget the comma!
>>> (1) -> 1
Non-mutable lists. Elements can be accessed same way
Empty tuples have a special syntactic form
>>> () -> ()
>>> tuple() -> ()
39. >>> yellow = (255, 255, 0) # r, g, b
>>> one = (1,)>>> one = (1,)
>>> yellow[0]
>>> yellow[1:]
(255, 0)
>>> yellow[0] = 0
Traceback (most recent call last):Traceback (most recent call last):
File "<stdin>", line 1, in <module>File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignmentTypeError: 'tuple' object does not support item assignment
Very common in string interpolation:
>>> "%s lives in %s at latitude %.1f" % ("Andrew", "Sweden",
57.7056)
40. >>> t = (23, ‘abc’, 4.56, (2,3), ‘def’)
>>> t[2] = 3.14
Traceback (most recent call last):
File "<pyshell#75>", line 1, in -toplevel-
tu[2] = 3.14
TypeError: object doesn't support item assignment
You can’t change a tuple.
You can make a fresh tuple and assign its reference to a
previously used name.
>>> t = (23, ‘abc’, 3.14, (2,3), ‘def’)
The immutability of tuples means they’re faster than lists.
41. Lists slower but more powerful than tuples
Lists can be modified, and they have lots of handy
operations and methods
Tuples are immutable and have fewer features
To convert between tuples and lists use the list() and
tuple() functions:
li = list(tu)
tu = tuple(li)
44. Boolean test whether a value is inside a container:
>>> t = [1, 2, 4, 5]
>>> 2 in t
True
>>> 4 not in t
False
For strings, tests for substrings
>>> a = 'abcde'
>>> 'c' in a
True
>>> 'cd' in a
True
45. The + operator produces a new tuple, list, or string whose
value is the concatenation of its arguments.
>>> (1, 2, 3) + (4, 5, 6)
(1, 2, 3, 4, 5, 6)
>>> [1, 2, 3] + [4, 5, 6]
[1, 2, 3, 4, 5, 6]
>>> “Hello” + “ ” + “World”
‘Hello World’
46. The * operator produces a new tuple, list, or string that
“repeats” the original content.
>>> (1, 2, 3) * 3
(1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> [1, 2, 3] * 3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> “Hello” * 3
‘HelloHelloHello’
47. smiles = "C(=N)(N)N.C(=O)(O)Osmiles = "C(=N)(N)N.C(=O)(O)O""
>>> smiles.find("(O)")
15
>>> smiles.find(".")
9
>>> smiles.find(".", 10)
-1
>>> smiles.split(".")
['C(=N)(N)N', 'C(=O)(O)O']
Use “find” to find the
start of a substring.
Start looking at position 10.
Find returns -1 if it couldn’t
find a match.
Split the string into parts
with “.” as the delimiter
48. if "Br" in “Brother”:
print "contains brother“
>>> contains brother
email_address = “ravi”
if "@" not in email_address:
email_address += "@latentview.com“
print email_address
>>> ravi@latentview.com
49. >>> line = " # This is a comment line n"
>>> line.strip()
'# This is a comment line'
>>> line.rstrip()
' # This is a comment line'
>>> line.rstrip("n")
' # This is a comment line '
51. capitalize() -- Capitalizes first letter of string
count(str, beg= 0,end=len(string))
Counts how many times str occurs in string.
encode(encoding=’UTF-8′,errors=’strict’)
Returns encoded string version of string
isalnum()
Returns true if string has at least 1 character
isalpha()
Returns true if string has at least 1 character
isdigit()
Returns true if string contains only digits and false
otherwise
52. Strings are read only
>>> s = "andrew"
>>> s[0] = "A"
Traceback (most recent call last):Traceback (most recent call last):
File "<stdin>", line 1, in <module>File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignmentTypeError: 'str' object does not support item assignment
>>> s = "A" + s[1:]
>>> s
'Andrew‘
53. n -> newline
t -> tab
-> backslash
...
But Windows uses backslash for directories!
filename = "M:nickel_projectreactive.smi" # DANGER!
filename = "M:nickel_projectreactive.smi" # Better!
filename = "M:/nickel_project/reactive.smi" # Usually works
54. Dictionaries are lookup tables.
Random, not sorted
They map from a “key” to a “value”.
symbol_to_name = {
"H": "hydrogen",
"He": "helium",
"Li": "lithium",
"C": "carbon",
"O": "oxygen",
"N": "nitrogen"
}
Duplicate keys are not allowed
Duplicate values are just fine
Keys can be any immutable value
59. dict.clear()
Removes all elements of dictionary dict
dict.fromkeys()
Create a new dictionary with keys from seq and
values set to value
dict.setdefault(key, default=None)
Similar to get(), but will set dict[key]=default if key is not
already in dict
dict.update(dict2)
Adds dictionary dict2‘s key-values pairs to dict
60. Keys must be immutable:
numbers, strings, tuples of immutables
▪ these cannot be changed after creation
reason is hashing (fast lookup technique)
not lists or other dictionaries
▪ these types of objects can be changed "in place"
no restrictions on values
Keys will be listed in arbitrary order
again, because of hashing
62. var2 = 0
if var2:
print "2 - Got a true
expression value"
print var2
else:
print "2 - Got a false
expression value"
print var2
print "Good bye!“
2 - Got a false expression
value 0 Good bye!
var1 = 100
if var1:
print "1 - Got a true
expression value"
print var1
else:
print "1 - Got a false
expression value"
print var1
1 - Got a true expression
value 100
63. count = 0
while (count < 9):
print 'The count is:',
count count = count + 1
print "Good bye!“
The count is: 0 The count is: 1
The count is: 2 The count is: 3
The count is: 4 The count is: 5
The count is: 6 The count is: 7
The count is: 8 Good bye!
Error with the program
var = 1
while var == 1 :
# This constructs an
infinite loop
num = raw_input("Enter a
number :")
print "You entered: ",
num print "Good bye!"
64. for i in range(20):
if i%3 == 0:
print i
if i%5 == 0:
print "Bingo!"
print "---“
for letter in 'Python':
# First Example
print 'Current Letter :', letter
fruits = ['banana', 'apple', 'mango']
for fruit in fruits:
# Second Example print 'Current fruit :', fruit
print "Good bye!"
65. def name(arg1, arg2, ...):
"""documentation""" # optional doc string
statements
return # from procedure
return expression # from function
def add():
return 5
>>>print add()
5
66. def functionname( parameters ):
"function_docstring" function_suite
return [expression]
def printme( str ):
"This prints a passed string into this function"
print str
print ‘n’
# Now you can call printme function
printme ("I'm first call to user defined function!")
printme("Again second call to the same function")
67. def gcd(a, b):
"greatest common divisor"
while a != 0:
a, b = b%a, a # parallel assignment
return b
>>> gcd.__doc__
'greatest common divisor'
>>> gcd(12, 20)
4
69. class Stack:
"A well-known data structure…"
def __init__(self): # constructor
self.items = []
def push(self, x):
self.items.append(x)
def pop(self):
x = self.items[-1]
del self.items[-1]
return x
def empty(self):
return len(self.items) == 0 # Boolean result
70. To create an instance, simply call the class object:
x = Stack() # no 'new' operator!
To use methods of the instance, call using dot notation:
x.empty() # -> 1
x.push(1) # [1]
x.empty() # -> 0
x.push("hello")# [1, "hello"]
x.pop() # -> "hello" # [1]
To inspect instance variables, use dot notation:
x.items # -> [1]
71. When a Python program starts it only has access to a
basic functions and classes.
(“int”, “dict”, “len”, “sum”, “range”, ...)
“Modules” contain additional functionality
Use “import” to tell Python to load a module
>>> import math #Used for mathematical functions
>>> import nltk #Used for NLP operations
72. Importing modules:
import re; print re.match("[a-z]+", s)
from re import match; print match("[a-z]+", s)
Import with rename:
import re as regex
from re import match as m
Before Python 2.0:
▪ import re; regex = re; del re
75. BeautifulSoup – A bit slow, but useful and easy for
beginners
Numpy – Advanced mathematical functionalities
SciPy – Algorithms and mathematical tools for python
Matplotlib – plotting library. Excellent graphs
Scrapy – Advanced Web scraping
NLTK - Natural Language Toolkit (Pattern, TextBlob)
IPython – Notebooks
Scikit-learn – machine learning on Python
Pandas –
Gensim – Topic Modelling
http://
76. a, X, 9, < -- ordinary characters just match themselves exactly. The meta-
characters which do not match themselves because they have special meanings
are: . ^ $ * + ? { [ ] | ( ) (details below)
. (a period) -- matches any single character except newline 'n'
w -- (lowercase w) matches a "word" character: a letter or digit or underbar [a-
zA-Z0-9_]. Note that although "word" is the mnemonic for this, it only matches
a single word char, not a whole word. W (upper case W) matches any non-
word character.
b -- boundary between word and non-word
s -- (lowercase s) matches a single whitespace character -- space, newline,
return, tab, form [ nrtf]. S (upper case S) matches any non-whitespace
character.
t, n, r -- tab, newline, return
d -- decimal digit [0-9] (some older regex utilities do not support but d, but
they all support w and s)
^ = start, $ = end -- match the start or end of the string
-- inhibit the "specialness" of a character. So, for example, use . to match a
period or to match a slash. If you are unsure if a character has special
meaning, such as '@', you can put a slash in front of it, @, to make sure it is
treated just as a character.
77. ## Search for pattern 'iii' in string 'piiig'.
## All of the pattern must match, but it may appear anywhere
## On success, match.group() is matched text.
match = re.search(r'iii', 'piiig') => found, match.group() == "iii"
match = re.search(r'igs', 'piiig') => not found, match == None
## . = any char but n
match = re.search(r'..g', 'piiig') => found, match.group() == "iig"
## d = digi , w = word
match = re.search(r'ddd', 'p123g') => found, match.group() ==
"123“
match = re.search(r'www', '@@abcd!!') => found,
match.group() == "abc"
78. + -- 1 or more occurrences of the pattern to its left, e.g. 'i+' = one or more i's
* -- 0 or more occurrences of the pattern to its left
? -- match 0 or 1 occurrences of the pattern to its left
## i+ = one or more i's, as many as possible.
match = re.search(r'pi+', 'piiig') => found, match.group() == "piii"
## Finds the first/leftmost solution, and within it drives the +
## as far as possible (aka 'leftmost and largest').
## In this example, note that it does not get to the second set of i's.
match = re.search(r'i+', 'piigiiii') => found, match.group() == "ii"
## s* = zero or more whitespace chars
## Here look for 3 digits, possibly separated by whitespace.
match = re.search(r'ds*ds*d', 'xx1 2 3xx') => found, match.group() == "1 2 3"
match = re.search(r'ds*ds*d', 'xx12 3xx') => found, match.group() == "12 3"
match = re.search(r'ds*ds*d', 'xx123xx') => found, match.group() == "123"
## ^ = matches the start of string, so this fails:
match = re.search(r'^bw+', 'foobar') => not found, match == None
## but without the ^ it succeeds:
match = re.search(r'bw+', 'foobar') => found, match.group() == "bar“
https://developers.google.com/edu/python/regular-expressions
80. Used for cleanup
f = open(file)
try:
process_file(f)
finally:
f.close()# always executed
print "OK" # executed on success only
81. Gives an idea where the error happened
For example, in nested loops
raise IndexError
raise IndexError("k out of range")
raise IndexError, "k out of range"
try:
something
except: # catch everything
print "Oops"
raise # reraise
82. “w” = “write mode”
“a” = “append mode”
“wb” = “write in binary”
“r” = “read mode” (default)
“rb” = “read in binary”
“U” = “read files with Unix
or Windows line endings”
>>> f = open(“names.txt")
>>> f.readline()
‘‘Ravin‘Ravin‘
>>> f.read()
‘‘Ravin‘Ravin‘
‘‘Shankarn’Shankarn’
83. >>> lst= [ x for x in open("text.txt","r").readlines() ]
>>> lst
['Chen Linn', 'clin@brandeis.edun', 'Volen 110n', 'Office['Chen Linn', 'clin@brandeis.edun', 'Volen 110n', 'Office
Hour: Thurs. 3-5n', 'n', 'Yaqin Yangn',Hour: Thurs. 3-5n', 'n', 'Yaqin Yangn',
'yaqin@brandeis.edun', 'Volen 110n', 'Offiche Hour:'yaqin@brandeis.edun', 'Volen 110n', 'Offiche Hour:
Tues. 3-5n']Tues. 3-5n']
input_file = open(“in.txt")
output_file = open(“out.txt", "w")
for line in input_file:
output_file.write(line)
84. >>> import csv
>>> with open('eggs.csv', 'rb') as csvfile:
... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
... for row in spamreader:
... print ', '.join(row)
Spam, Spam, Spam, Spam, Spam, Baked Beans Spam,
Lovely Spam, Wonderful Spam
>>> with open('eggs.csv', 'wb') as csvfile:
spamwriter = csv.writer(csvfile)
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
>>> w = csv.writer(open(Fn,'ab'),dialect='excel')
85.
86. Python is a great language for NLP:
Simple
Easy to debug:
▪ Exceptions
▪ Interpreted language
Easy to structure
▪ Modules
▪ Object oriented programming
Powerful string manipulation
87. Here is a description from the NLTK official site:
“NLTK is a leading platform for building Python programs
to work with human language data. It provides easy-to-use
interfaces to over 50 corpora and lexical resources such as
WordNet, along with a suite of text processing libraries for
classification, tokenization, stemming, tagging, parsing,
and semantic reasoning.”
88. A software package for manipulating linguistic data and
performing NLP tasks
Advanced tasks are possible from an early stage
Permits projects at various levels
Consistent interfaces
Facilitates reusability of modules
Implemented in Python
89. The token class to encode information about NL texts.
Each token instance represents a unit of text such as a
word, a text, or a document.
A given instance is defined by a partial mapping from
property names to property values.
TreebankWordTokenizer
WordPunctTokenizer
PunctWordTokenizer
WhitespaceTokenizer
91. In linguistic morphology and information retrieval, stemming is the
process for reducing inflected (or sometimes derived) words to their
stem, base or root form—generally a written word form. The stem
need not be identical to the morphological root of the word; it is
usually sufficient that related words map to the same stem, even if this
stem is not in itself a valid root.
Stemming programs are commonly referred to as stemming
algorithms or stemmers.
Helpful in reducing the vocabulary in large scale operations
95. Lemmatisation (or lemmatization) in linguistics, is the process of
grouping together the different inflected forms of a word so they can
be analysed as a single item.
Lemmatisation is closely related to stemming. The difference is that a
stemmer operates on a single word without knowledge of the context,
and therefore cannot discriminate between words which have different
meanings depending on part of speech. However, stemmers are
typically easier to implement and run faster, and the reduced accuracy
may not matter for some applications.
97. Stanford POS Tagger
Stanford Named Entity Recognizer
english_nertagger.tag(‘Rami Eid is studying at Stony Brook University in NY’.split())
Out[3]:
[(u’Rami’, u’PERSON’),
(u’Eid’, u’PERSON’),
(u’is’, u’O’),
(u’studying’, u’O’),
(u’at’, u’O’),
(u’Stony’, u’ORGANIZATION’),
(u’Brook’, u’ORGANIZATION’),
(u’University’, u’ORGANIZATION’),
(u’in’, u’O’),
(u’NY’, u’O’)]
Stanford Parser
98. Stanford Parser
english_parser.raw_parse_sents((“this is the english parser test”, “the parser is from
stanford parser”))
Out[4]:
[[u’this/DT is/VBZ the/DT english/JJ parser/NN test/NN’],
[u'(ROOT’,
u’ (S’,
u’ (NP (DT this))’,
u’ (VP (VBZ is)’,
u’ (NP (DT the) (JJ english) (NN parser) (NN test)))))’],
99. Part of Speech Tagging
Parsing
Word Net
Named Entity
Recognition
Information Retrieval
Sentiment Analysis
Document Clustering
Topic Segmentation
Authoring
Machine Translation
Summarization
Information Extraction
Spoken Dialog Systems
Natural Language
Generation
Word Sense
Disambiguation
100. Det Noun Verb Prep Adj
A 0.9 0.1 0 0 0
man 0 0.6 0.2 0 0.2
walks 0 0.2 0.8 0 0
into 0 0 0 1 0
bar 0 0.7 0.3 0 0