The document discusses Python functions, including defining functions with def statements, variable scopes according to the LEGB rule, passing arguments by assignment, and advanced function concepts like nested functions and nonlocal declarations to modify variables in enclosing scopes. It provides examples of function basics, scopes, arguments, and advanced function techniques in Python.
Introduction about Python by JanBask Training, we are offering Online Pyton Training. You should visit: http://www.janbasktraining.com/python/ for Pyton Training.
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
Open source general-purpose. Multiplatform programming language
Object Oriented, Procedural, Functional
Easy to interface with C/ObjC/Java/Fortran
Easy to interface with C++ (via SWIG)
Great interactive environment
Python 'philosophy' emphasis readability, clarity and simplicity
The Interactive Interpreter
it is very easy to learn and understand.
Introduction about Python by JanBask Training, we are offering Online Pyton Training. You should visit: http://www.janbasktraining.com/python/ for Pyton Training.
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
Open source general-purpose. Multiplatform programming language
Object Oriented, Procedural, Functional
Easy to interface with C/ObjC/Java/Fortran
Easy to interface with C++ (via SWIG)
Great interactive environment
Python 'philosophy' emphasis readability, clarity and simplicity
The Interactive Interpreter
it is very easy to learn and understand.
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Introduction To Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
Introduction To Python
Keywords And Identifiers
Variables And Data Types
Operators
Loops In Python
Functions
Classes And Objects
OOPS Concepts
File Handling
YouTube Video: https://youtu.be/uYjRzbP5aZs
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This presentation educates you about Python and the reason for learning python, Key advantages of learning Python, Characteristics of Python, Hello World using Python syntax and Applications of Python.
For more topics stay tuned with Learnbay.
Python An Introduction, A presentation Developed by Swarit Wadhe. This Slide Will Give you basic information about python (Origin, Codes and difference from other languages).
I hope you'll find this helpfull and if you do please share it with your fellows.
What is Python? An overview of Python for science.Nicholas Pringle
A brief introduction on the use of Python for scientists. Python is fast becoming a popular programming language for scientists. It is free, open source and constantly improving. Being an easy language to learn, it has a large a community of users. Its many favourable qualities make it the perfect language for scientific collaboration.
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 0: Python Overview
0. Python Introduction
1. What is Python?
2. Story of Python
3. Why Python
4. Use of Python
5. Python Download + Installation
6. How to Use? + Online Course Resource
1. Variable, Data Type, Expression
1. Create First Python Program File
2. First Program - Hello World
3. Comment
4. Variable + Data Type + Example
5. Variable Naming Convention
6. Practice 0.1
2. Input/ Output
1. Input/ Output (String)
1. A String Input & Output
2. Display A Message in Print & Input function
3. Check Data Type
4. Practice 0.2
2. Input/ Output (Number)
1. An Integer Number Input & Output + Check Data Type
2. Type Conversion
3. A Float Number Input & Output + Check Data Type
4. Built-in Function with Example
5. Practice 0.3
3. Formatted Input Output
El que és meu, és teu? Del consum compulsiu, individual i material (hiperconsum) al consum col·laboratiu
Es pot consumir i col·laborar alhora? Aquests termes semblen oposats i fins ara potser ho han estat. Però la conjuntura actual de crisi econòmica, social i ambiental ens condueix vers nous models de negoci que basen el seu èxit en compartir i intercanviar productes i serveis.
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Introduction To Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
Introduction To Python
Keywords And Identifiers
Variables And Data Types
Operators
Loops In Python
Functions
Classes And Objects
OOPS Concepts
File Handling
YouTube Video: https://youtu.be/uYjRzbP5aZs
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This presentation educates you about Python and the reason for learning python, Key advantages of learning Python, Characteristics of Python, Hello World using Python syntax and Applications of Python.
For more topics stay tuned with Learnbay.
Python An Introduction, A presentation Developed by Swarit Wadhe. This Slide Will Give you basic information about python (Origin, Codes and difference from other languages).
I hope you'll find this helpfull and if you do please share it with your fellows.
What is Python? An overview of Python for science.Nicholas Pringle
A brief introduction on the use of Python for scientists. Python is fast becoming a popular programming language for scientists. It is free, open source and constantly improving. Being an easy language to learn, it has a large a community of users. Its many favourable qualities make it the perfect language for scientific collaboration.
Python Programming Course Lecture by IoT Code Lab Training.
Discussed Topic:
Chapter 0: Python Overview
0. Python Introduction
1. What is Python?
2. Story of Python
3. Why Python
4. Use of Python
5. Python Download + Installation
6. How to Use? + Online Course Resource
1. Variable, Data Type, Expression
1. Create First Python Program File
2. First Program - Hello World
3. Comment
4. Variable + Data Type + Example
5. Variable Naming Convention
6. Practice 0.1
2. Input/ Output
1. Input/ Output (String)
1. A String Input & Output
2. Display A Message in Print & Input function
3. Check Data Type
4. Practice 0.2
2. Input/ Output (Number)
1. An Integer Number Input & Output + Check Data Type
2. Type Conversion
3. A Float Number Input & Output + Check Data Type
4. Built-in Function with Example
5. Practice 0.3
3. Formatted Input Output
El que és meu, és teu? Del consum compulsiu, individual i material (hiperconsum) al consum col·laboratiu
Es pot consumir i col·laborar alhora? Aquests termes semblen oposats i fins ara potser ho han estat. Però la conjuntura actual de crisi econòmica, social i ambiental ens condueix vers nous models de negoci que basen el seu èxit en compartir i intercanviar productes i serveis.
This slide deck that Mr. Minh Tran - KMS's Software Architect shared at "Java-Trends and Career Opportunities" seminar of Information Technology Center of HCMC University of Science.
Der selbstfahrende Koffer von travelmate robotics: Mithilfe von Infrarotsensoren folgt der Koffer seinem Besitzer und kann dabei seine Geschwindigkeit anpassen. Der Koffer ist an das Smartphone des Nutzers gekoppelt. Er kann Gegenstände erkennen und umfahren.
[Webinar] Test First, Fail Fast - Simplifying the Tester's Transition to DevOpsKMS Technology
DevOps is a spectacular mish-mash of development and operations processes and practices that has been growing increasingly popular in recent years. With the upward trending rate in adoption comes the need for organizations to fully understand the key practices as well as thoroughly integrating team members, especially testers, throughout the delivery pipeline. Getting started with DevOps practices can be a little tricky when choosing the right tools, people, and processes. In this webinar, we’ll focus on helping you make the switch without diminishing the team’s delivered product quality, so that the transition meets the enterprise objectives of speed and reliability.
Tune in to learn:
The biggest concern when moving to DevOps - and how to handle it
Why you need ‘Coding Testers’
The best tools for the job
The process of failing fast, and its significance to testers
Measuring the transition - recommended metrics
The value of DevOps long-term - efficiency, repeatability & reliability
Don’t worry about failing - it’s a part of the process!
Excellence Technology is one of the top ISO satisfied company in Chandigarh and Mohali . We provide Best industrial training Digital marketing, PHP.java, best web designing training ,software testing ,Python Course In Chandigarh etc . It can be provided 6 month and 28 days industrial training & tuition classes.
This is a presentation which is an introduction to python language.
The presentation is contributed by me for educational purpose and this presentation is
Only introduction.
The Basic python data types and how to use python for Data Science,
Excellence Technology is one of the best python training institute in Chandigarh. Python is one of the most trending technology in these days. It is a general purpose programming language. That’s why, you can use the programming language for developing both desktop and web applications. to become a full stack web developer is always the best choice. Excellence Technology is the top ISO Satisfied company in Chandigarh & Mohali. It provides best digital marketing training, PHP , Java, top Python course in Chandigarh and also providing 6months/3months/45days/28days industrial training with best practical knowledge.
Advanced level Python Course with 100% Job Assistance Guarantee Provided. We Have 3 Sessions Per Week And 90 Hours Certified Basic Python Classes In Thane Training Offered By Asterix Solution
Visit: http://www.asterixsolution.com/python-training-in-mumbai.html
Duration - 90 hrs
Sessions - 3 per week
Project - 3
Student - 12 per Batch
Introduction to Python for Security ProfessionalsAndrew McNicol
This webcast introduces Python for security professionals. The goal is to inspire others to push past the initial learning curve to harness the power of Python. This is just a quick glance at the power that awaits anyone willing to gain the skill. If you are looking for more resources check out DrapsTV's YouTube channel.
In Python, data types define the type of data that can be stored and manipulated in variables. Python is a dynamically typed language, meaning you don't need to explicitly declare the data type of a variable; Python infers it based on the value assigned to the variable.
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
This is a two-day course in Python programming aimed at professional programmers. The course material provided here is intended to be used by teachers of the language, but individual learners might find some of this useful as well.
The course assume the students already know some Python, but that they feel a need to establish a solid understanding of the language to further develop their skills.
The course is released under Creative Commons Attribution 4.0. Its primary location (along with some sample solutions and the original PowerPoint) is at https://github.com/JonJagger/two-day-courses/tree/master/pf
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Training python (new Updated)
1. TRAINING PYTHON
INTRODUCTION TO PYTHON
(BASIC LEVEL)
Editor: Nguyễn Đức Minh Khôi
@HCMC University of Technology, September 2011
2. 9/2/2011 Training Python Chapte 0: Introduction to Python 1
TRAINING PYTHON
Chapter 0: INTRODUCTION TO PYTHON
3. 9/2/2011 Training Python Chapte 0: Introduction to Python 2
CONTENTS
Python in general
How Python program runs?
How to run Python?
4. 9/2/2011 Training Python Chapte 0: Introduction to Python 3
Python in general
• What is python?
• High level programming language
• Emphasize on code readability
• Very clear syntax + large and comprehensive standard library
• Use of indentation for block delimiters
• Multiprogramming paradigm: OO, imperative, functional,
procedural, reflective
• A fully dynamic type system and automatic memory management
• Scripting language + standalone executable program + interpreter
• Can run on many platform: Windows, Linux, Mactonish
• Updates:
• Newest version: 3.2.2 (CPython, JPython, IronPython)
• Website: www.python.org
5. 9/2/2011 Training Python Chapte 0: Introduction to Python 4
Python in general (Cont’)
• Advantages:
• Software quality
• Developer productivity
• Program portability
• Support libraries
• Component integration
• Enjoyment
• Disadvantages:
• not always be as fast as that of compiled languages such as C and
C++
6. 9/2/2011 Training Python Chapte 0: Introduction to Python 5
Python in general (Cont’)
• Applications of python:
7. 9/2/2011 Training Python Chapte 0: Introduction to Python 6
Python in general (Cont’)
• Python’s Capability:
• System Programming
• GUI
• Internet Scripting
• Component Integration
• Database Programming
• Rapid Prototyping
• Numeric and Scientific Programming
• Gaming, Images, Serial Ports, XML, Robots, and More
8. 9/2/2011 Training Python Chapte 0: Introduction to Python 7
How Python program runs?
Notice: pure Python code runs at speeds somewhere between those of
a traditional compiled language and a traditional interpreted language
9. 9/2/2011 Training Python Chapte 0: Introduction to Python 8
How to run Python?
• Install Python 3.2.2:
• Go to website:
http://www.python.org/download/ and
download the latest version of Python
• Run and install follow the instructions
of the .msi file
• If you successfully install, you will see
this picture:
• Coding Python:
• Not IDE support: use notepad++
http://notepad-plus-plus.org/
• Use IDE support: Eclipse (3.7) or
Netbeans (7.0)
10. 9/2/2011 Training Python Chapte 0: Introduction to Python 9
How to run Python? (Cont’)
• Install Eclipse: follow the instructions from this website:
http://wiki.eclipse.org/FAQ_Where_do_I_get_and_install_Eclipse%3F
(you should download the Eclipse Classics version)
• Install Pydev plugin for eclipse: follow this instruction:
http://pydev.org/manual_101_install.html
11. 9/2/2011 Training Python Chapte 0: Introduction to Python 10
THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part I – Getting Started
Learning Python – O’reilly
14. 5/22/2011 Training Python 3
Lists
• Ordered collections of arbitrary objects
• Accessed by offset
• Variable-length, heterogeneous, and arbitrarily nestable
• Of the category “mutable sequence”
• Arrays of object references
15. 5/22/2011 Training Python 4
Lists literals and operations
16. 5/22/2011 Training Python 5
Lists literals and operations (cont’)
17. 5/22/2011 Training Python 6
Dictionaries
• Accessed by key, not offset
• Accessed by key, not offset
• Variable-length, heterogeneous, and arbitrarily nestable
• Of the category “mutable mapping”
• Tables of object references (hash tables)
18. 5/22/2011 Training Python 7
Dictionaries literals and operations
19. 5/22/2011 Training Python 8
Dictionaries literals and operations (c)
20. 5/22/2011 Training Python 9
Tuples
• Ordered collections of arbitrary objects
• Accessed by offset
• Of the category “immutable sequence”
• Fixed-length, heterogeneous, and arbitrarily nestable
• Arrays of object references
21. 5/22/2011 Training Python 10
Tuples literals and operations
22. 5/22/2011 Training Python 11
Tuples literals and operations (con’t)
23. 5/22/2011 Training Python 12
Files – common operations
24. 2
NUMERIC TYPES
• Integers and floating-point numbers
• Complex numbers
• Fixed-precision decimal numbers
• Rational fraction numbers
• Sets
• Booleans
• Unlimited integer precision
• A variety of numeric built-ins and modules
27. Dynamic Typing
• Variables, Objects, References:
• Variables are entries in a system table, with spaces for links to
objects.
• Objects are pieces of allocated memory, with enough space to
represent the values for which they stand.
• References are automatically followed pointers from variables to
objects.
29. Dynamic Typing (Cont’) - Shared references
• Mutable types:
• Notices:
• It’s also just the default: if you don’t want such behavior, you can
request that Python copy objects instead of making references.
30. Dynamic Typing (Cont’) - Shared references
• Notices (next):
• “is” function returns False if the names point to equivalent but different
objects, as is the case when we run two different literal expressions.
• Small integers and strings are cached and reused, though, is tells us
they reference the same single object.
31. 5/22/2011 Training Python 13
Summary
• Object just classification
32. 5/22/2011 Training Python 14
Summary (con’t)
• Object Flexibility
• Lists, dictionaries, and tuples can hold any kind of object.
• Lists, dictionaries, and tuples can be arbitrarily nested.
• Lists and dictionaries can dynamically grow and shrink.
• Object copy
• Slice expressions with empty limits (L[:]) copy sequences.
• The dictionary and set copy method (X.copy()) copies a dictionary
or set.
• Some built-in functions, such as list, make copies (list(L)).
• The copy standard library module makes full copies.
33. 9/2/2011 Learning Python Chapter 1 1
THANKS FOR LISTENING
Editor: Nguy n Đ c Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part II – Types and Operations
Learning Python – O’reilly
34. 9/2/2011 Learning Python Chapter 2 1
TRAINING PYTHON
STATEMENTS AND SYNTAX
40. 9/2/2011 Learning Python Chapter 2 7
Assignment Statements
Assignment Properties:
• Assignments create object references
• Names are created when first assigned
• Names must be assigned before being referenced
• Some operations perform assignments implicitly
Assignment Statement Forms:
41. 9/2/2011 Learning Python Chapter 2 8
Variable name rules (opt)
• Syntax: (underscore or letter) + (any number of letters,
digits, or underscores)
• Case matters: SPAM is not the same as spam
• Reserved words are off-limits
44. 9/2/2011 Learning Python Chapter 2 11
Conditional Statements - IF
• General Format:
• The if/else ternary expression:
• Example:
45. 9/2/2011 Learning Python Chapter 2 12
IF Statements - Truth tests (opt)
Conditional expression:
• Any nonzero number or nonempty object is true.
• Zero numbers, empty objects, and the special object None are
considered false.
• Comparisons and equality tests are applied recursively to data
structures.
• Comparisons and equality tests return True or False (custom versions
of 1 and 0).
• Boolean “and” and “or” operators return a true or false operand
object.
46. 9/2/2011 Learning Python Chapter 2 13
IF Statements - Truth tests (opt) (Cont)
• “and” and “or” operands:
47. 9/2/2011 Learning Python Chapter 2 14
Loop Statements – while statements
• General while format:
• Notice:
48. 9/2/2011 Learning Python Chapter 2 15
Loop Statements – for statements
• General Format:
• Loop Coding Techniques:
• The built-in range function produces a series of successively higher
integers, which can be used as indexes in a for.
• The built-in zip function returns a series of parallel-item tuples,
which can be used to traverse multiple sequences in a for.
• Notice: for loops typically run quicker than while-based counter
loops, it’s to your advantage to use tools like these that allow you to
use for when possible.
50. 9/2/2011 Learning Python Chapter 2 17
Iterations and comprehensions
• Iterable:
• an object is considered iterable if it is either a physically stored
sequence or an object that produces one result at a time in the
context of an iteration tool like a for loop.
• iterable objects include both physical sequences and virtual
sequences computed on demand.
• Iterations:
• Any object with a __next__ method to advance to a next result,
which raises StopIteration at the end of the series of results, is
considered iterable in Python.
• Example:
51. 9/2/2011 Learning Python Chapter 2 18
List comprehension
• Example:
• (x + 10): arbitrary expression
• (for x in L): iterable object
• Extend List Comprehension:
54. 9/2/2011 Learning Python Chapter 2 21
THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part III – Statements and Syntax
Learning Python – O’reilly
55. 9/6/2011 Training Python Chapter 3 1
TRAINING PYTHON
Chapter 3: FUNCTION
56. 9/6/2011 Training Python Chapter 3 2
CONTENTS
Function Basics
Scope
Arguments
Function Advanced
Iterations and Comprehension Advanced
57. 9/6/2011 Training Python Chapter 3 3
Function Basics
• Function: A function is a device that groups a set of
statements so they can be run more than once in a
program.
• Why use?:
• Maximizing code reuse and minimizing redundancy
• Procedural decomposition
58. 9/6/2011 Training Python Chapter 3 4
Function Basics – def Statements
• General format:
• Use “def” statements:
59. 9/6/2011 Training Python Chapter 3 5
Function Basics – Examples
60. 9/6/2011 Training Python Chapter 3 6
Scopes
• Three different scopes
• If a variable is assigned inside a def, it is local to that function.
• If a variable is assigned in an enclosing def, it is nonlocal to nested
functions.
• If a variable is assigned outside all defs, it is global to the entire file.
• Notice:
• All names assigned inside a function def statement (or a lambda,
an expression we’ll meet later) are locals by default.
• Functions can freely use names as-signed in syntactically
enclosing functions and the global scope, but they must declare
such nonlocals and globals in order to change them.
61. 9/6/2011 Training Python Chapter 3 7
Scopes – the LEGB rules
62. 9/6/2011 Training Python Chapter 3 8
Scopes – examples
Global names: X, func
Local names: Y, Z
# The Built – in Scopes
63. 9/6/2011 Training Python Chapter 3 9
Scopes – Global statements
• Global Statement:
• Other ways to access Globals:
64. 9/6/2011 Training Python Chapter 3 10
Scopes – Global statements(Cont’)
65. 9/6/2011 Training Python Chapter 3 11
Scopes – Nested functions
• Factory function
• These terms refer to a function object that remembers values in enclosing
scopes regardless of whether those scopes are still present in memory.
66. 9/6/2011 Training Python Chapter 3 12
Scopes – Nested scope (Cont’)
• Nested scope and lambda:
67. 9/6/2011 Training Python Chapter 3 13
Scopes – Nonlocal statements
• The nonlocal statement:
• Is a close cousin to global
• Like global: nonlocal declares that a name will be changed in an
enclosing scope.
• Unlike global:
• nonlocal applies to a name in an enclosing function’s scope, not the
global module scope outside all defs.
• nonlocal names must already exist in the enclosing function’s scope
when declared
• Format:
69. 9/6/2011 Training Python Chapter 3 15
Arguments – Passing Basics
• Arguments are passed by automatically assigning objects to local
variable names.
• Assigning to argument names inside a function does not affect the
caller.
• Changing a mutable object argument in a function may impact the
caller.
• Immutable arguments are effectively passed “by value.”
• Mutable arguments are effectively passed “by pointer.”
70. 9/6/2011 Training Python Chapter 3 16
Arguments – Matching Modes
• Keyword-only arguments: arguments that must be passed by keyword
only and will never be filled in by a positional argument.
71. 9/6/2011 Training Python Chapter 3 17
Arguments - Examples
74. 9/6/2011 Training Python Chapter 3 20
Function Advanced
• General guidelines:
• Coupling: use arguments for inputs and return for outputs.
• Coupling: use global variables only when truly necessary.
• Coupling: don’t change mutable arguments unless the caller
expects it.
• Cohesion: each function should have a single, unified purpose.
• Size: each function should be relatively small.
• Coupling: avoid changing variables in another module file directly.
75. 9/6/2011 Training Python Chapter 3 21
Function Advanced - Recursions
• Examples:
• Alternatives:
76. 9/6/2011 Training Python Chapter 3 22
Function Advanced – Lambda Expression
• Lambda format:
• Use lambda for:
• inline a function definition
• defer execution of a piece of code
• Notices:
• lambda is an expression, not a statement
• lambda’s body is a single expression, not a block of statements.
• If you have larger logic to code, use def; lambda is for small pieces of
inline code. On the other hand, you may find these techniques useful in
moderation
• Examples:
77. 9/6/2011 Training Python Chapter 3 23
Lambda Expression (Cont’)
• Logic within lambda function:
• Nested lambda:
• Used with map function:
• Used with filter function:
• Used with reduce function:
78. 9/6/2011 Training Python Chapter 3 24
Iterations and Comprehension Part 2
• List Comprehension:
• Vs. Map:
• Vs. filter:
• Vs. Nested for:
79. 9/6/2011 Training Python Chapter 3 25
Iterations and Comprehension Part 2
• Generators:
• Generator functions: are coded as normal def statements but use
yield statements to return results one at a time, suspending and
resuming their state between each.
• Generator expressions: are similar to the list comprehensions
of the prior section, but they return an object that produces results
on demand instead of building a result list.
• Generator functions:
80. 9/6/2011 Training Python Chapter 3 26
Iterations and Comprehension Part 2
• Generator Expression:
81. 9/6/2011 Training Python Chapter 3 27
3.0 Comprehension Syntax
82. 9/6/2011 Training Python Chapter 3 28
Function Pitfall
• “List comprehensions were nearly twice as fast as equivalent for
loop statements, and map was slightly quicker than list
comprehensions when mapping a built-in function such as abs
(absolute value)”
• Python detects locals statically, when it compiles the def’s code,
rather than by noticing assignments as they happen at runtime.
83. 9/6/2011 Learning Python Chapter 2 29
THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part IV – Functions
Learning Python 4th Edition – O’reilly 2010
85. 9/15/2011 Training Python Chapter 4 2
Contents
Modules Basics
Modules Package
Modules in advance
86. 9/15/2011 Training Python Chapter 4 3
Modules Basics
• Modules are process with:
• import: Lets a client (importer) fetch a module as a whole
• from: Allows clients to fetch particular names from a module
• imp.reload: Provides a way to reload a module’s code without
stopping Python
• Why use Modules?
• Code reuse
• System namespace partitioning
• Implementing service or data
87. 9/15/2011 Training Python Chapter 4 4
Modules Basics – import statements
• How imports work?
1. Find the module’s file.
2. Compile it to byte code (if needed).
3. Run the module’s code to build the objects it defines.
• The Module Search Path:
1. The home directory of the program
2. PYTHONPATH directories (if set)
3. Standard library directories
4. The contents of any .pth files (if present)
88. 9/15/2011 Training Python Chapter 4 5
Modules Basics – create Modules
• In fact, both the names of module files and the names of
directories used in package must conform to the rules for
variable names:
• They may, for instance, contain only letters, digits, and
underscores.
• Package directories also cannot contain platform-specific syntax
such as spaces in their names.
• Modules in Python can be written in external languages
such as C/C++ in Cpython, Java in Jython, .net languages
in IronPython
89. 9/15/2011 Training Python Chapter 4 6
Modules Basics - Usages
• The import statement:
• The from statement:
• The from * statement
• The import happens only once
90. 9/15/2011 Training Python Chapter 4 7
Modules Basics – Usages (Con’t)
• Import assigns an entire module object to a single name.
• From assigns one or more names to objects of the same names in
another module.
Be careful:
91. 9/15/2011 Training Python Chapter 4 8
Modules Basics - namespaces
• Files generate Namespaces:
• Module statements run on the first import.
• Top-level assignments create module attributes.
• Module namespaces can be accessed via the attribute__dict__or dir(M)
• Modules are a single scope (local is global)
• Namespace nesting:
• In mod3.py:
• In mod2.py:
• In mod1.py:
92. 9/15/2011 Training Python Chapter 4 9
Modules Basics – reloading function
• Unlike import and from:
• reload is a function in Python, not a statement.
• reload is passed an existing module object, not a name.
• reload lives in a module in Python 3.0 and must be imported itself.
• How to use:
93. 9/15/2011 Training Python Chapter 4 10
Modules Basics – reload example
• In changer.py:
• Change global message variable:
•
94. 9/15/2011 Training Python Chapter 4 11
Modules package
• Package __init__.py files:
• Directory: dir0dir1dir2mod.py
• Import statement: import dir1.dir2.mod
• Rules:
• dir1 and dir2 both must contain an __init__.py file.
• dir0, the container, does not require an __init__.py file; this file will
simply be ignored if present.
• dir0, not dir0dir1, must be listed on the module search path (i.e., it must
be the home directory, or be listed in your PYTHONPATH, etc.).
• Present in tree mode:
95. 9/15/2011 Training Python Chapter 4 12
Modules package
• Relative import:
• instructs Python to import a module named spam located in the
same package directory as the file in which this statement appears.
• Sibling import:
96. 9/15/2011 Training Python Chapter 4 13
Modules In Advance – Data Hiding
• Minimizing from * Damage: _X and __all__
• you can prefix names with a single underscore (e.g., _X) to prevent
them from being copied out when a client imports a module’s
names with a from * statement.
• Enabling future language features
• Mixed Usage Modes: __name__ and __main__
• If the file is being run as a top-level program file, __name__ is set
to the string "__main__" when it starts.
• If the file is being imported instead, __name__ is set to the
module’s name as known by its clients
97. 9/15/2011 Training Python Chapter 4 14
Modules in Advance (Cont’)
• In runme.py:
• Unit Tests with __name__:
• we can wrap up the self-test call in a __name__ check, so that it
will be launched only when the file is run as a top-level script, not
when it is imported
98. 9/15/2011 Training Python Chapter 4 15
Modules in Advance (Cont’)
• The as Extension for import and from:
99. 9/15/2011 Training Python Chapter 4 16
Module Gotchas
• Statement Order Matters in Top-Level Code
• from Copies Names but Doesn’t Link
• from * Can Obscure the Meaning of Variables
• Recursive from Imports May Not Work
• You can usually eliminate import cycles like this by careful design—
maximizing cohesion and minimizing coupling are good first steps.
100. THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part V – Modules
Learning Python 4th Edition – O’reilly 2010
102. 9/18/2011 Training Python Chapter 5: Classes and OOP 2
Contents
Class Coding Basics
Class Coding Detail
Advanced Class topics
103. 9/18/2011 Training Python Chapter 5: Classes and OOP 3
Class Coding Basics
• OOP program must show:
• Abstraction (or sometimes called encapsulation)
• Inheritance (vs. composition)
• Polymorphism
• Class vs. Instance Object:
• Class: Serve as instance factories. Their attributes provide
behavior—data and functions—that is inherited by all the instances
generated from them.
• Instance: Represent the concrete items in a program’s domain.
Their attributes record data that varies per specific object
104. 9/18/2011 Training Python Chapter 5: Classes and OOP 4
Class Coding Basics (Cont’)
• Each class statement generates a new class object.
• Each time a class is called, it generates a new instance object.
• Instances are automatically linked to the classes from which they are created.
• Classes are linked to their superclasses by listing them in parentheses in a class
header line; the left-to-right order there gives the order in the tree.
105. 9/18/2011 Training Python Chapter 5: Classes and OOP 5
Class Coding Basics – Class trees
• Notice:
• Python uses multiple inheritance: if there is more than one
superclass listed in parentheses in a class statement (like C1’s
here), their left-to-right order gives the order in which those
superclasses will be searched for attributes.
• Attributes are usually attached to classes by assignments made
within class statements, and not nested inside function def
statements.
• Attributes are usually attached to instances by assignments to a
special argument passed to functions inside classes, called self.
106. 9/18/2011 Training Python Chapter 5: Classes and OOP 6
Class Coding Basics - Class vs. Instance
• Class Object:
• The class statement creates a class object and assigns it a name.
• Assignments inside class statements make class attributes.
• Class attributes provide object state and behavior.
• Instance Object:
• Calling a class object like a function makes a new instance object.
• Each instance object inherits class attributes and gets its own
namespace.
• Assignments to attributes of self in methods make per-instance
attributes.
108. 9/18/2011 Training Python Chapter 5: Classes and OOP 8
Class Coding Basics - Inheritance
• Attribute inheritance:
• Superclasses are listed in parentheses in a class header.
• Classes inherit attributes from their superclasses.
• Instances inherit attributes from all accessible classes.
• Each object.attribute reference invokes a new, independent search.
• Logic changes are made by subclassing, not by changing
superclasses.
110. 9/18/2011 Training Python Chapter 5: Classes and OOP 10
Class Coding Details
• Class statement:
Assigning names inside the class statement makes class attributes,
and nested defs make class methods, but other assignments make
attributes, too.
• Examples:
119. 9/18/2011 Training Python Chapter 5: Classes and OOP 19
Advanced Class topics - Relationships
• Is – relationship vs. has - relationship
In employees.py file
Express: inheritance
– is relationship
121. 9/18/2011 Training Python Chapter 5: Classes and OOP 21
Advanced Class topics – Extending built in types
• By embedding:
122. 9/18/2011 Training Python Chapter 5: Classes and OOP 22
Advanced Class topics – Extending built in types
• By subclassing:
123. 9/18/2011 Training Python Chapter 5: Classes and OOP 23
Advanced Class topics –
Diamond Inheritance
• Old and new style inheritance:
124. 9/18/2011 Training Python Chapter 5: Classes and OOP 24
Advanced Class topics –
Diamond Inheritance
• Explicit Conflict Resolution:
125. 9/18/2011 Training Python Chapter 5: Classes and OOP 25
Advanced Class topics –
static class method
• Notice:
126. 9/18/2011 Training Python Chapter 5: Classes and OOP 26
Advanced Class topics –
static and class method
127. 9/18/2011 Training Python Chapter 5: Classes and OOP 27
Advanced Class topics - Decorators
• Function decorators provide a way to specify special operation
modes for functions, by wrapping them in an extra layer of logic
implemented as another function.
• Syntax:
• Example:
129. 9/18/2011 Training Python Chapter 5: Classes and OOP 29
Advanced Class topics – Class gotchas
• Changing Class Attributes Can Have Side Effects
• Changing Mutable Class Attributes Can Have Side
Effects, Too
• Multiple Inheritance: Order Matters
• multiple inheritance works best when your mix-in classes are as
self-contained as possible—because they may be used in a variety
of contexts, they should not make assumptions about names
related to other classes in a tree.
130. THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part VI – Classes and OOP
Learning Python 4th Edition – O’reilly 2010
131. TRAINING PYTHON
INTRODUCTION TO PYTHON
(BASIC LEVEL)
Editor: Nguyễn Đức Minh Khôi
@HCMC University of Technology, September 2011
133. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 3
Contents
Basic Concepts
Exception in Details
Examples
134. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 4
Basic Concepts
• What is Exceptions:
• Are events that can modify the flow of control through a program
• Are triggered automatically on errors, and they can be triggered and
intercepted by your code.
• What is Exception Handlers:
• Try statement
• Roles of Exceptions:
• Error Handling
• Event Notification
• Special case Handling
• Termination Actions
• Unusual control flows
135. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 5
Basic Concepts (cont.)
• Suppose we have the function like this:
• Default handler:
• Catching Exception:
138. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 8
Contents
Basic Concepts
Exception in Details
Examples
139. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 9
Exception in Details
• Try statement clauses:
140. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 10
Exception in Details (cont.)
• How it runs?
• If an exception does occur while the try block’s statements are running,
Python jumps back to the try and runs the statements under the first
except clause that matches the raised exception. Control resumes below
the entire try statement after the except block runs (unless the except
block raises another exception).
• If an exception happens in the try block and no except clause matches,
the exception is propagated up to the last matching try statement that
was entered in the program or, if it’s the first such statement, to the top
level of the process (in which case Python kills the program and prints a
default error message).
• If no exception occurs while the statements under the try header run,
Python runs the statements under the else line (if present), and control
then resumes below the entire try statement
141. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 11
Exception in Details (cont.)
• Notices:
• Except:
Vs.
• Else:
• Vs.
142. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 12
Exception in Details (cont.)
• Try/finally statement:
• How it works?
• If no exception occurs while the try block is running, Python jumps back
to run the finally block and then continues execution past below the try
statement.
• If an exception does occur during the try block’s run, Python still comes
back and runs the finally block, but it then propagates the exception up
to a higher try or the top-level default handler; the program does not
resume execution below the try statement. That is, the finally block is
run even if an exception is raised, but unlike an except, the finally does
not terminate the exception—it continues being raised after the finally
block runs.
143. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 13
Exception in Details (cont.)
• Nested Exception Handlers:
144. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 14
Exception in Details (cont.)
• The Raise statement
• Example
• Propagating Exception with raise:
145. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 15
Exception in Details (cont.)
• The Assert Statement
• Example:
146. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 16
Exception in Details (cont.)
• Your own Exception Class:
superclass called General and two subclasses
called Specific1 and Specific2
Exception is the Superclass Of all Exception Class
147. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 17
Exception in Details
• Python Built in Exception:
• You can use directly or inherit
them to your own Exception
148. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 18
Contents
Basic Concepts
Exception in Details
Examples
149. 7/13/2012 Training Python @HCMUT Summer 2012 - Chapter 6 19
Examples
• The try/finally statement examples:
• allows you to specify cleanup actions that always must occur, such as file
closes and server disconnects.
151. THANKS FOR LISTENING
Editor: Nguyễn Đức Minh Khôi
Contact: nguyenducminhkhoi@gmail.com
Main reference: Part VI – Classes and OOP
Learning Python 4th Edition – O’reilly 2010