An introduction to Python programming, covering Python's basic types and built-in collections, file handling, iteration, and designing basic scripts from scratch. Presented at the University of Georgia in Fall 2009, 2010, 2011 and 2012.
The complete example script and sample input text can be downloaded at:
https://gist.github.com/661869
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
This document provides an overview of a Python Foundation course that introduces Python concepts and programming style. The course covers Python history and culture, multi-paradigm programming in Python including procedural, modular, scripting, object-oriented and functional styles. It also covers Python syntax, logic and flow control, built-in data types, classes and objects. The course includes coding experiments, programming labs and homework assignments.
This file contains the first steps any beginner can take as he/she starts a journey into the rich and beautiful world of Python programming. From basics such as variables to data types and recursions, this document touches briefly on these concepts. It is not, by any means, an exhaustive guide to learn Python, but it serves as a good starting point and motivation.
( ** Python Certification Training: https://www.edureka.co/python ** )
This Edureka PPT on Advanced Python tutorial covers all the important aspects of using Python for advanced use-cases and purposes. It establishes all of the concepts like system programming , shell programming, pipes and forking to show how wide of a spectrum Python offers to the developers.
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
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
Python is an interpreted, object-oriented programming language created by Guido van Rossum in 1990. It has a clear, readable syntax and is designed to be highly extensible. Python code is often much shorter than equivalent code in other languages like C++ or Java due to features like indentation-based blocks and dynamic typing. It is used for web development, scientific computing, and more.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is an interpreted, interactive, object-oriented language with a simple syntax. Python supports cross-platform development and is widely used for scripting, game development, and building desktop and mobile applications. To use Python, developers must download the Python interpreter and can write and run code using the interactive shell or integrated development environments like IDLE. The document then discusses Python's multi-paradigm programming style, advantages like rapid development, and how to install Python and write basic programs using variables, operators, and data types.
Kunal Chauhan will be conducting a 6 week Python training program from May 15th to June 26th. The training will cover introductory Python programming, basics of programming in Python including variables, data types, operators, and control flow, principles of object-oriented programming, SQLite database usage, GUI development with PyQt, and applications of Python in various disciplines like web development, machine learning, data science, and more.
This document provides an introduction to Python fundamentals. It discusses Python's character set, tokens or lexical units including keywords, identifiers, literals, operators, and punctuators. It also covers Python programming concepts such as variables and assignments, functions, comments, statements, and programming conventions regarding whitespace, maximum line length, and case sensitivity. The document aims to explain the basic building blocks of the Python language to learn Python programming.
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
This document provides an overview of a Python Foundation course that introduces Python concepts and programming style. The course covers Python history and culture, multi-paradigm programming in Python including procedural, modular, scripting, object-oriented and functional styles. It also covers Python syntax, logic and flow control, built-in data types, classes and objects. The course includes coding experiments, programming labs and homework assignments.
This file contains the first steps any beginner can take as he/she starts a journey into the rich and beautiful world of Python programming. From basics such as variables to data types and recursions, this document touches briefly on these concepts. It is not, by any means, an exhaustive guide to learn Python, but it serves as a good starting point and motivation.
( ** Python Certification Training: https://www.edureka.co/python ** )
This Edureka PPT on Advanced Python tutorial covers all the important aspects of using Python for advanced use-cases and purposes. It establishes all of the concepts like system programming , shell programming, pipes and forking to show how wide of a spectrum Python offers to the developers.
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
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
Python is an interpreted, object-oriented programming language created by Guido van Rossum in 1990. It has a clear, readable syntax and is designed to be highly extensible. Python code is often much shorter than equivalent code in other languages like C++ or Java due to features like indentation-based blocks and dynamic typing. It is used for web development, scientific computing, and more.
Python is a general purpose programming language created by Guido van Rossum in 1991. It is an interpreted, interactive, object-oriented language with a simple syntax. Python supports cross-platform development and is widely used for scripting, game development, and building desktop and mobile applications. To use Python, developers must download the Python interpreter and can write and run code using the interactive shell or integrated development environments like IDLE. The document then discusses Python's multi-paradigm programming style, advantages like rapid development, and how to install Python and write basic programs using variables, operators, and data types.
Kunal Chauhan will be conducting a 6 week Python training program from May 15th to June 26th. The training will cover introductory Python programming, basics of programming in Python including variables, data types, operators, and control flow, principles of object-oriented programming, SQLite database usage, GUI development with PyQt, and applications of Python in various disciplines like web development, machine learning, data science, and more.
This document provides an introduction to Python fundamentals. It discusses Python's character set, tokens or lexical units including keywords, identifiers, literals, operators, and punctuators. It also covers Python programming concepts such as variables and assignments, functions, comments, statements, and programming conventions regarding whitespace, maximum line length, and case sensitivity. The document aims to explain the basic building blocks of the Python language to learn Python programming.
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
Python Advanced – Building on the foundationKevlin 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 Python, to the level taught in the Python Foundation course: http://www.slideshare.net/Kevlin/python-foundation-a-programmers-introduction-to-python-concepts-style)
The course is released under Creative Commons Attribution 4.0. Its primary location (along with the original PowerPoint) is at https://github.com/JonJagger/two-day-courses/tree/master/pa
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
Presented at DevSum (2018-05-31)
The SOLID principles are often presented as being core to good code design practice. Each of S, O, L, I and D do not, however, necessarily mean what programmers expect they mean or are taught. By understanding this range of beliefs we can learn more about practices for objects, components and interfaces than just S, O, L, I and D.
This talk reviews the SOLID principles and reveals contradictions and different interpretations. It is through paradoxes and surprises we often gain insights. We will leave SOLID somewhat more fluid, but having learnt from them more than expected.
This document provides an agenda and overview for a Python tutorial presented over multiple sessions. The first session introduces Python and demonstrates how to use the Python interpreter. The second session covers basic Python data structures like lists, modules, input/output, and exceptions. An optional third session discusses unit testing. The document explains that Python is an easy to learn yet powerful programming language that supports object-oriented programming and high-level data structures in an interpreted, dynamic environment.
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
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
This document provides a side-by-side comparison of code samples in R and Python for common data science tasks. It covers topics like IDEs, data operations, manipulation, visualization, machine learning, text mining and more. For each topic, the document lists the main packages/functions used in R and Python and provides brief code examples. The goal is to give beginners a basic introduction to how similar tasks are accomplished in both languages.
This document provides an overview of Python programming concepts including what Python is, variables, data types, operators, conditional statements, loops, functions, exceptions, lists, dictionaries, tuples and more. Some key points covered include:
- Python is an interpreted, object-oriented programming language that can be used for many different application types.
- Variables, constants, operators, and control flow structures like conditionals and loops are introduced as the basic building blocks of Python programs.
- Common data types like strings, lists, dictionaries and tuples are described along with their characteristics and functions.
- Other concepts explained are functions, exceptions, formatting, modules and more.
Python modules allow for code reusability and organization. There are three main components of a Python program: libraries/packages, modules, and functions/sub-modules. Modules can be imported using import, from, or from * statements. Namespaces and name resolution determine how names are looked up and associated with objects. Packages are collections of related modules and use an __init__.py file to be recognized as packages by Python.
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on Python Functions tutorial covers all the important aspects of functions in Python right from the introduction to what functions are, all the way till checking out the major functions and using the code-first approach to understand them better.
Agenda
Why use Functions?
What are the Functions?
Types of Python Functions
Built-in Functions in Python
User-defined Functions in Python
Python Lambda Function
Conclusion
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
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 document provides an introduction to Java programming concepts such as data types, variables, operators, input/output, control flow, methods, and classes. It explains what computer science and programming are, gives examples of basic Java programs using print statements, and discusses programming fundamentals like program structure, naming conventions, comments, and static methods. Methods are introduced as a way to organize code and eliminate redundancy. Overall, the document orients the reader to fundamental Java programming concepts.
The document discusses Python interview questions and answers related to Python fundamentals like data types, variables, functions, objects and classes. Some key points include:
- Python is an interpreted, interactive and object-oriented programming language. It uses indentation to identify code blocks rather than brackets.
- Python supports dynamic typing where the type is determined at runtime. It is strongly typed meaning operations inappropriate for a type will fail with an exception.
- Common data types include lists (mutable), tuples (immutable), dictionaries, strings and numbers.
- Functions use def, parameters are passed by reference, and variables can be local or global scope.
- Classes use inheritance, polymorphism and encapsulation to create
This document provides an overview of the Python programming language. It covers Python basics like syntax, datatypes, modules, and control structures. It also discusses topics like functions, classes, files, and popular Python modules. The document contains an agenda that outlines these topics and provides code samples to illustrate Python concepts hands-on. It aims to equip readers with foundational Python programming knowledge.
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
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 document provides an overview of the Python programming language. It discusses what Python is, its key features, who uses it, common applications, and how to download and install Python. It then covers Python syntax concepts like identifiers, keywords, multiline statements, docstrings, indentation, comments, and string formatting. The document also introduces Python data types like numbers, strings, lists, tuples, dictionaries, sets and how to work with them. It describes how to convert between number types and access/update strings and lists. Finally, it discusses Python development environments like Anaconda and Spyder.
This document provides an introduction and overview of the Python programming language. It covers Python's history and key features such as being object-oriented, dynamically typed, batteries included, and focusing on readability. It also discusses Python's syntax, types, operators, control flow, functions, classes, imports, error handling, documentation tools, and popular frameworks/IDEs. The document is intended to give readers a high-level understanding of Python.
This Presentation is a draft of a summary of "Learn Python The Hard Way" Book which is very helpful for anyone want to learn python from scratch of
For reading the book and do exercises, the book is available for free here: http://learnpythonthehardway.org/book/
This document provides an overview of Google Code-in (GCI) and resources on GitHub. It discusses how GitHub can be used for more than just software, including sharing data, writing, translations, and open company initiatives. It also summarizes GCI tips like choosing a project in advance, getting familiar with tools and communication practices, and practicing communicating without overly formal language. Finally, it introduces the loklak social media harvester project and some example tasks for GCI Challenge 2.
The one-day AP GoPo workshop runs from 8am to 3pm with a morning break around 10am, lunch from 12pm to 1pm, and a graduation ceremony concluding the day at 2:47pm. The schedule includes infographic bellringers, sharing teacher stories, and exploring what, how, and why participants teach through thinking and doing activities. The workshop goals are to cover AP structure, government and politics content, and provide practical, useful, and inspiring takeaways for participants.
Python Advanced – Building on the foundationKevlin 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 Python, to the level taught in the Python Foundation course: http://www.slideshare.net/Kevlin/python-foundation-a-programmers-introduction-to-python-concepts-style)
The course is released under Creative Commons Attribution 4.0. Its primary location (along with the original PowerPoint) is at https://github.com/JonJagger/two-day-courses/tree/master/pa
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
Presented at DevSum (2018-05-31)
The SOLID principles are often presented as being core to good code design practice. Each of S, O, L, I and D do not, however, necessarily mean what programmers expect they mean or are taught. By understanding this range of beliefs we can learn more about practices for objects, components and interfaces than just S, O, L, I and D.
This talk reviews the SOLID principles and reveals contradictions and different interpretations. It is through paradoxes and surprises we often gain insights. We will leave SOLID somewhat more fluid, but having learnt from them more than expected.
This document provides an agenda and overview for a Python tutorial presented over multiple sessions. The first session introduces Python and demonstrates how to use the Python interpreter. The second session covers basic Python data structures like lists, modules, input/output, and exceptions. An optional third session discusses unit testing. The document explains that Python is an easy to learn yet powerful programming language that supports object-oriented programming and high-level data structures in an interpreted, dynamic environment.
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
The document provides an introduction to Python programming including its features, uses, history, and installation process. Some key points covered include:
- Python is an interpreted, object-oriented programming language that is used for web development, scientific computing, and desktop applications.
- It was created by Guido van Rossum in 1991 and named after the Monty Python comedy group.
- To install Python on Windows, users download the latest version from python.org and run the installer, which also installs the IDLE development environment.
- The document then covers basic Python concepts like variables, data types, operators, and input/output functions.
This document provides a side-by-side comparison of code samples in R and Python for common data science tasks. It covers topics like IDEs, data operations, manipulation, visualization, machine learning, text mining and more. For each topic, the document lists the main packages/functions used in R and Python and provides brief code examples. The goal is to give beginners a basic introduction to how similar tasks are accomplished in both languages.
This document provides an overview of Python programming concepts including what Python is, variables, data types, operators, conditional statements, loops, functions, exceptions, lists, dictionaries, tuples and more. Some key points covered include:
- Python is an interpreted, object-oriented programming language that can be used for many different application types.
- Variables, constants, operators, and control flow structures like conditionals and loops are introduced as the basic building blocks of Python programs.
- Common data types like strings, lists, dictionaries and tuples are described along with their characteristics and functions.
- Other concepts explained are functions, exceptions, formatting, modules and more.
Python modules allow for code reusability and organization. There are three main components of a Python program: libraries/packages, modules, and functions/sub-modules. Modules can be imported using import, from, or from * statements. Namespaces and name resolution determine how names are looked up and associated with objects. Packages are collections of related modules and use an __init__.py file to be recognized as packages by Python.
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on Python Functions tutorial covers all the important aspects of functions in Python right from the introduction to what functions are, all the way till checking out the major functions and using the code-first approach to understand them better.
Agenda
Why use Functions?
What are the Functions?
Types of Python Functions
Built-in Functions in Python
User-defined Functions in Python
Python Lambda Function
Conclusion
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
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 document provides an introduction to Java programming concepts such as data types, variables, operators, input/output, control flow, methods, and classes. It explains what computer science and programming are, gives examples of basic Java programs using print statements, and discusses programming fundamentals like program structure, naming conventions, comments, and static methods. Methods are introduced as a way to organize code and eliminate redundancy. Overall, the document orients the reader to fundamental Java programming concepts.
The document discusses Python interview questions and answers related to Python fundamentals like data types, variables, functions, objects and classes. Some key points include:
- Python is an interpreted, interactive and object-oriented programming language. It uses indentation to identify code blocks rather than brackets.
- Python supports dynamic typing where the type is determined at runtime. It is strongly typed meaning operations inappropriate for a type will fail with an exception.
- Common data types include lists (mutable), tuples (immutable), dictionaries, strings and numbers.
- Functions use def, parameters are passed by reference, and variables can be local or global scope.
- Classes use inheritance, polymorphism and encapsulation to create
This document provides an overview of the Python programming language. It covers Python basics like syntax, datatypes, modules, and control structures. It also discusses topics like functions, classes, files, and popular Python modules. The document contains an agenda that outlines these topics and provides code samples to illustrate Python concepts hands-on. It aims to equip readers with foundational Python programming knowledge.
** Python Certification Training: https://www.edureka.co/python **
This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT:
Introduction to Python
Reasons to choose Python
Installing and running Python
Development Environments
Basics of Python Programming
Starting with code
Python Operators
Python Lists
Python Tuples
Python Sets
Python Dictionaries
Conditional Statements
Looping in Python
Python Functions
Python Arrays
Classes and Objects (OOP)
Conclusion
Follow us to never miss an update in the future.
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 document provides an overview of the Python programming language. It discusses what Python is, its key features, who uses it, common applications, and how to download and install Python. It then covers Python syntax concepts like identifiers, keywords, multiline statements, docstrings, indentation, comments, and string formatting. The document also introduces Python data types like numbers, strings, lists, tuples, dictionaries, sets and how to work with them. It describes how to convert between number types and access/update strings and lists. Finally, it discusses Python development environments like Anaconda and Spyder.
This document provides an introduction and overview of the Python programming language. It covers Python's history and key features such as being object-oriented, dynamically typed, batteries included, and focusing on readability. It also discusses Python's syntax, types, operators, control flow, functions, classes, imports, error handling, documentation tools, and popular frameworks/IDEs. The document is intended to give readers a high-level understanding of Python.
This Presentation is a draft of a summary of "Learn Python The Hard Way" Book which is very helpful for anyone want to learn python from scratch of
For reading the book and do exercises, the book is available for free here: http://learnpythonthehardway.org/book/
This document provides an overview of Google Code-in (GCI) and resources on GitHub. It discusses how GitHub can be used for more than just software, including sharing data, writing, translations, and open company initiatives. It also summarizes GCI tips like choosing a project in advance, getting familiar with tools and communication practices, and practicing communicating without overly formal language. Finally, it introduces the loklak social media harvester project and some example tasks for GCI Challenge 2.
The one-day AP GoPo workshop runs from 8am to 3pm with a morning break around 10am, lunch from 12pm to 1pm, and a graduation ceremony concluding the day at 2:47pm. The schedule includes infographic bellringers, sharing teacher stories, and exploring what, how, and why participants teach through thinking and doing activities. The workshop goals are to cover AP structure, government and politics content, and provide practical, useful, and inspiring takeaways for participants.
The document discusses different media models and how the media shapes public opinion. It presents two media models - old media which includes newspapers, network TV, radio and magazines that had gatekeepers and aimed to be objective and factual, and new media which includes the internet, cable, blogs and direct mail that is non-hierarchical, slanted and opinion-based. It then questions how much power the media has to shape public opinion and lists some factors that limit media influence, such as political socialization, selectivity, needs, and recall and comprehension.
The document contains a series of prompts and short passages about various topics including "Two Truths and a Lie" guessing games, facts about high school students and media consumption, information about the UNCSA, and messages encouraging learning about politics, citizenship, and the AP Government and Politics exam.
This one-day workshop on venture capital will be facilitated by Douglas Abrams, who has experience as a Wharton MBA, JP Morgan vice president, co-founder of two venture capital funds, founder of an incubator fund and advisory, and professor at NUS and Sasin business schools. The workshop will cover the VC mindset of risk and return correlation, reasons for raising investment and investing in venture capital, key elements of successful companies, venture finance terms, company valuation methods, and how VCs make money through exits. It will also discuss the stages of funding, calculating investor ROI including dilution, capitalization tables, key deal elements, and the VC-startup negotiation process.
1. The document outlines the agenda and content covered during the first day of a social media and communication skills workshop in Poland.
2. Participants learned about creating online profiles, setting up blogs, capturing and editing photos and videos, and interacting on social media platforms.
3. Key topics included establishing an online presence, writing blog posts, managing conversations and potential crises on social media, and eliciting engagement with posts. Participants practiced these skills and received guidance from workshop facilitators.
This document provides an overview of the Python programming language in 7 sentences or less:
The document outlines why Python is useful, how to run Python code, basic data types and operators in Python, statements and functions, and some useful Python packages and resources. It discusses that Python is an easy to learn, powerful, and portable programming language that supports object-oriented programming and is free and open source. The document also provides examples of running Python code directly from the interpreter and from script files.
The type of a value refers to the kind of data it represents. In Python, the main types are:
- int - integer numbers like 1, 2, 100
- float - floating point numbers like 1.5, 3.14159
- str - strings, sequences of characters like 'hello'
- bool - boolean values True or False
When you write code, Python assigns a type to each value. The type determines how it can be used and what operations are valid on it. For example, you can add two integers but not add an integer to a string. Checking and understanding types is important for writing correct Python code.
The slides shown here have been used for talks given to scientists in informal contexts.
Python is introduced as a valuable tool for both producing and evaluating data.
The talk is essentially a guided tour of the author's favourite parts of the Python ecosystem. Besides the Python language itself, NumPy and SciPy as well as Matplotlib are mentioned.
A last part of the talk concerns itself with code execution speed. With this problem in sight, Cython and f2py are introduced as means of glueing different languages together and speeding Python up.
The source code for the slides, code snippets and further links are available in a git repository at
https://github.com/aeberspaecher/PythonForScientists
The document provides information about various Python concepts like PEP 8, pickling, lambda functions, generators, modules, packages and more. It also includes questions about memory management in Python, tools for static analysis, decorators, iterators, slicing, and other common Python interview questions.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
Python lists are mutable while tuples are immutable. Some key features of Python include being an interpreted, dynamically typed language well-suited for object-oriented programming. Python uses indentation to specify blocks of code within functions, classes, loops, etc. and functions are first-class objects that can be assigned to variables or passed into other functions.
This document provides an introduction to the Python programming language. It begins with an agenda that covers running Python, Python programming concepts like data types and control flows, and hands-on exercises. It then discusses running Python interactively and as programs, Python syntax and basic data types like numbers, strings, lists, dictionaries, and tuples. The document is intended to help users understand the basic structure of Python and write simple Python scripts.
Slides from Phil Pennington\'s talk on Using Parallel Computing with Visual Studio 2010 and .NET 4.0, originally presented at the North Houston .NET Users Group (facebook.com/nhdnug).
The document provides information about a course on Object Oriented Programming concepts in Python. It outlines 6 course outcomes related to illustrating Python basics, developing scripts using control statements and data types, constructing object oriented programs using functions, and applying concepts like inheritance, polymorphism, and exception handling. It also mentions the syllabus, books and references, and provides introductory information about Python including its history, uses, installation process, interpreted nature, and basic programming concepts.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
The document provides an overview of a hands-on workshop on the Python programming language conducted by Abdul Haseeb for a faculty development program. The workshop covers the basics of Python including its history, design philosophy, why it is popular, how to get started with the Python IDE, basic data types, variables, operators, input/output functions, and differences between Python versions 2 and 3. Examples are provided to demonstrate various Python concepts like strings, integers, floats, lists, tuples, dictionaries, functions to convert between types, and string operations. Comparisons between Python and C/C++ highlight differences in syntax, commenting, error handling and code readability.
Python is an interpreted, object-oriented programming language created by Guido van Rossum in 1990. It has a clear, readable syntax and is used for rapid prototyping, scripting, web development and more. Key features of Python include its clean syntax, extensive standard library, readability, extensibility via C/C++, and emphasis on code readability and maintenance through use of whitespace and comments.
This document discusses training on Python that was conducted over six weeks by Cetpa Infotech Pvt. Ltd. It covers topics like what Python is, the differences between programs and scripting languages, Python's history and uses. It also discusses installing Python IDEs and provides examples of Python code, variables, data types, strings, lists, tuples, and control flow statements. The conclusion is that Python is a good teaching language due to being free, easy to install, and flexible for both procedural and object-oriented programming.
This document contains slides from a Python workshop presentation. It introduces Python, discussing its history, philosophy, features, and how to write Python code. Some key points covered include:
- Python was created in the late 1980s and named after Monty Python.
- It aims to have clear, readable syntax while also being powerful.
- Python code tends to be more concise than languages like Java and C++.
- It uses indentation rather than braces to define code blocks.
- Common data types like lists, dictionaries, and tuples are covered.
- Basic programming constructs like conditionals, loops, functions and file I/O are demonstrated.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
The document outlines the topics covered in a 5-day Certified Python Programmer For Data Science course. Day 1 covers an introduction to programming and Python basics. Day 2 covers Jupyter Notebook, functions, modules, object-oriented programming. Day 3 covers working with files, JSON data, and web scraping. Day 4 introduces NumPy, Pandas, and Matplotlib for data analysis and visualization. Day 5 covers machine learning and a capstone project.
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON Nandakumar P
Unit 1 : INTRODUCTION TO PROBLEM SOLVING, EXPRESSION AND DATA TYPES
Fundamentals: what is computer science - Computer Algorithms - Computer Hardware - Computer software - Computational problem solving using the Python programming language - Overview of Python, Environmental Setup, First program in Python, Python I/O Statement. Expressions and Data Types: Literals, Identifiers and Variables, Operators, Expressions. Data types, Numbers, Type Conversion, Random Number.
Problem solving: Restaurant Tab calculation and Age in seconds.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
Generating privacy-protected synthetic data using Secludy and MilvusZilliz
During this demo, the founders of Secludy will demonstrate how their system utilizes Milvus to store and manipulate embeddings for generating privacy-protected synthetic data. Their approach not only maintains the confidentiality of the original data but also enhances the utility and scalability of LLMs under privacy constraints. Attendees, including machine learning engineers, data scientists, and data managers, will witness first-hand how Secludy's integration with Milvus empowers organizations to harness the power of LLMs securely and efficiently.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxSitimaJohn
Ocean Lotus cyber threat actors represent a sophisticated, persistent, and politically motivated group that poses a significant risk to organizations and individuals in the Southeast Asian region. Their continuous evolution and adaptability underscore the need for robust cybersecurity measures and international cooperation to identify and mitigate the threats posed by such advanced persistent threat groups.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Your One-Stop Shop for Python Success: Top 10 US Python Development Providersakankshawande
Simplify your search for a reliable Python development partner! This list presents the top 10 trusted US providers offering comprehensive Python development services, ensuring your project's success from conception to completion.
CAKE: Sharing Slices of Confidential Data on BlockchainClaudio Di Ciccio
Presented at the CAiSE 2024 Forum, Intelligent Information Systems, June 6th, Limassol, Cyprus.
Synopsis: Cooperative information systems typically involve various entities in a collaborative process within a distributed environment. Blockchain technology offers a mechanism for automating such processes, even when only partial trust exists among participants. The data stored on the blockchain is replicated across all nodes in the network, ensuring accessibility to all participants. While this aspect facilitates traceability, integrity, and persistence, it poses challenges for adopting public blockchains in enterprise settings due to confidentiality issues. In this paper, we present a software tool named Control Access via Key Encryption (CAKE), designed to ensure data confidentiality in scenarios involving public blockchains. After outlining its core components and functionalities, we showcase the application of CAKE in the context of a real-world cyber-security project within the logistics domain.
Paper: https://doi.org/10.1007/978-3-031-61000-4_16
CAKE: Sharing Slices of Confidential Data on Blockchain
Python workshop #1 at UGA
1. Getting started
How to design programs
Python concepts & party tricks
Python Workshop 2012
The essentials: getting started, program design, modules & I/O
Eric Talevich
Institute of Bioinformatics, University of Georgia
Nov. 8, 2012
Eric Talevich Python Workshop 2012
2. Getting started
How to design programs
Python concepts & party tricks
1 Getting started
2 How to design programs
Data structures
Algorithms
Interfaces
3 Python concepts & party tricks
File-like objects
Iteration
The csv module
Eric Talevich Python Workshop 2012
3. Getting started
How to design programs
Python concepts & party tricks
Getting started: Interpreter
Your interactive interpreter is one of:
python on the command line
IDLE — Integrated DeveLopment Environment for Python 1
We’ll use IDLE.
Run this in the interpreter:
import this
1
Included in the standard Python installation on Windows and Mac
Eric Talevich Python Workshop 2012
4. Getting started
How to design programs
Python concepts & party tricks
Getting started: Scripts
1 Write this in a new, blank text file:
print "Hello, Athens!"
Eric Talevich Python Workshop 2012
5. Getting started
How to design programs
Python concepts & party tricks
Getting started: Scripts
1 Write this in a new, blank text file:
print "Hello, Athens!"
2 Save it in plain-text format with the name hi.py in the same
directory as your interpreter session is running. Run it:
python hi.py
Eric Talevich Python Workshop 2012
6. Getting started
How to design programs
Python concepts & party tricks
Getting started: Scripts
1 Write this in a new, blank text file:
print "Hello, Athens!"
2 Save it in plain-text format with the name hi.py in the same
directory as your interpreter session is running. Run it:
python hi.py
A CREDIT Add a line at the top of hi.py to tell Unix this is a Python
script:
#!/usr/bin/env python
Make hi.py executable (from the terminal shell):
chmod +x hi.py
Now you don’t need the .py extension:
mv hi.py hi
./hi
Eric Talevich Python Workshop 2012
7. Getting started
How to design programs
Python concepts & party tricks
Getting started: Documentation
In the interpreter: help(function-or-module )
On the command line: pydoc function-or-module
In IDLE: <F1> (launches docs.python.org)
Also, type(obj ), dir(obj ), vars(obj ) and auto-completion
(tab or Ctrl+Space) are pretty handy.
Try it:
>>> help(str)
>>> s = ’Hello’
>>> type(s)
>>> dir(s)
>>> help(s.capitalize)
>>> help(help)
Eric Talevich Python Workshop 2012
8. Getting started
How to design programs
Python concepts & party tricks
Example: string methods
Find the string (str) methods to. . .
Convert gOoFy-cAsE words to title case, upper case or
lower case
Remove certain characters from either end
Align (justify) within a fixed width, padded by spaces
Eric Talevich Python Workshop 2012
9. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
How to design programs
Data structure: Organizes a collection of data units
Algorithm: Defines operations for a specific task
Interface: I/O, how a program interacts with the world
Theorem
Program = Data Structures + Algorithms + Interfaces
Eric Talevich Python Workshop 2012
10. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Data structures
Organize a program’s information
Eric Talevich Python Workshop 2012
11. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Units of data: Atoms
Class int float bool — str
Literal 1, -2 .1, 2.9e8 True, False None ’abc’
Try it:
>>> num = 0.000000002
>>> num
>>> type(num)
Features:
Create from a data literal or by calling the class name
(constructor)
Always immutable — assigning another value replaces the
original object
Eric Talevich Python Workshop 2012
12. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Collections of data
Class Literal Description
list [] Ordered array of arbitrary objects
dict {} Unordered map of fixed to arbitrary objects
set Unordered collection of fixed objects
Eric Talevich Python Workshop 2012
13. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Mutable vs. immutable objects
Some mutable objects have immutable counterparts:
list vs. tuple
set vs. frozenset
>>> x = (1, 2, 3)
>>> x[0] = 7
>>> y = list(x)
>>> y[0] = 7
>>> print y
Eric Talevich Python Workshop 2012
14. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Variables are names, not values
Mutable collections can be shared:
>>> x = [1, 2, 3]
>>> y = x
>>> y[0] = 4
>>> x is y
>>> print ’x =’, x, ’y =’, y
Reassigning to an immutable object replaces (changes the id of)
the original:
>>> x = (1, 2, 3)
>>> y = x
>>> y = (4, 2, 3)
>>> x is y
>>> print ’x =’, x, ’y =’, y
Eric Talevich Python Workshop 2012
15. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
a fairly short
Break
Eric Talevich Python Workshop 2012
16. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Algorithms
Specify operations
Eric Talevich Python Workshop 2012
17. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Control flow
Branching The if statement chooses between code paths:
x = -2
if x >= 0:
print x, "is positive"
else:
print x, "was negative"
x = -x
Eric Talevich Python Workshop 2012
18. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Control flow
Branching The if statement chooses between code paths:
x = -2
if x >= 0:
print x, "is positive"
else:
print x, "was negative"
x = -x
Iteration The for statement visits each element sequentially:
for x in [-2, -1, 0, 1, 2]:
if x >= 0:
print x, "is positive"
Eric Talevich Python Workshop 2012
19. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
# Define a function
# −−−−−−−−−−−−−−−−−
# T h i s e x a m p l e shows how t o d e f i n e a s i m p l e f u n c t i o n .
# The f u n c t i o n d e f i n i t i o n s t a r t s w i t h keyword ’ d e f ’ ,
# t h e n t h e name o f t h e f u n c t i o n and t h e a r g u m e n t s .
# The ’ d o c s t r i n g ’ i n q u o t e s i s o p t i o n a l , b u t n i c e .
# The r e s t o f t h e code , i n d e n t e d , i s t h e f u n c t i o n body .
#
# ( L i n e s t h a t b e g i n w i t h a h a s h (#) a r e comments . )
def n i c e a b s ( x ) :
””” R e t u r n t h e a b s o l u t e v a l u e o f a number . ”””
i f x < 0:
r e t u r n −x
else :
return x
Eric Talevich Python Workshop 2012
20. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Algorithms
Definition: A precise set of instructions for accomplishing a task.
We’ll treat an algorithm as one or more functions that operate on
some input data to produce some output according to a
specification.
Useful fact: The structure of a function will resemble the
structure of the data it operates on.
Eric Talevich Python Workshop 2012
21. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The design recipe: a general method
Steps, in order, for developing a program from scratch: 2
Contract: Name the function; specify the types (i.e. atoms and
data structures) of its input data and its output.
abs: number → positive number
2
http://htdp.org/2003-09-26/Book/curriculum-Z-H-1.html
Eric Talevich Python Workshop 2012
22. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The design recipe: a general method
Steps, in order, for developing a program from scratch: 2
Contract: Name the function; specify the types (i.e. atoms and
data structures) of its input data and its output.
abs: number → positive number
Purpose: Description of what the program does, in terms of
inputs and output — sufficient for a function
declaration and docstring.
2
http://htdp.org/2003-09-26/Book/curriculum-Z-H-1.html
Eric Talevich Python Workshop 2012
23. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The design recipe: a general method
Steps, in order, for developing a program from scratch: 2
Contract: Name the function; specify the types (i.e. atoms and
data structures) of its input data and its output.
abs: number → positive number
Purpose: Description of what the program does, in terms of
inputs and output — sufficient for a function
declaration and docstring.
Example: Function call with arguments, and expected result.
abs(-1) → 1
abs(1) → 1
2
http://htdp.org/2003-09-26/Book/curriculum-Z-H-1.html
Eric Talevich Python Workshop 2012
24. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The design recipe: a general method
Steps, in order, for developing a program from scratch: 2
Contract: Name the function; specify the types (i.e. atoms and
data structures) of its input data and its output.
abs: number → positive number
Purpose: Description of what the program does, in terms of
inputs and output — sufficient for a function
declaration and docstring.
Example: Function call with arguments, and expected result.
abs(-1) → 1
abs(1) → 1
Definition: The code!
Tests: Convert the example to actual code — by running
the program on it.
2
http://htdp.org/2003-09-26/Book/curriculum-Z-H-1.html
Eric Talevich Python Workshop 2012
25. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Example: Counting words in text
Given a sample text, count the frequencies of each word.
Name: wordcount
Input: A string of text.
Output: A dictionary, with string keys and integers values.
Eric Talevich Python Workshop 2012
26. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Example: Counting words in text
Given a sample text, count the frequencies of each word.
Name: wordcount
Input: A string of text.
Output: A dictionary, with string keys and integers values.
Purpose: Create a dictionary associating each unique word in
the text with the number of times it appears.
Eric Talevich Python Workshop 2012
27. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Example: Counting words in text
Given a sample text, count the frequencies of each word.
Name: wordcount
Input: A string of text.
Output: A dictionary, with string keys and integers values.
Purpose: Create a dictionary associating each unique word in
the text with the number of times it appears.
Example: wordcount("yes no yes no maybe")
→ {’yes’: 2, ’no’: 2, ’maybe’: 1}
Eric Talevich Python Workshop 2012
28. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
def w o r d c o u n t ( t e x t ) :
””” Count t h e o c c u r e n c e s o f e a c h word i n t e x t .
I n p u t : s t r i n g o f w h i t e s p a c e −d e l i m i t e d words
Output : d i c t o f s t r i n g s and i n t e g e r s ( >0)
Example :
>>> w o r d c o u n t ( ” y e s no y e s no maybe ” )
{ ’ maybe ’ : 1 , ’ y e s ’ : 2 , ’ no ’ : 2}
”””
w o r d c o u n t s = {}
f o r word i n t e x t . s p l i t ( ) :
i f word not i n w o r d c o u n t s :
# New word ; s t a r t c o u n t i n g from 0
w o r d c o u n t s [ word ] = 0
w o r d c o u n t s [ word ] += 1
return word counts
Eric Talevich Python Workshop 2012
29. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Snack Time
Eric Talevich Python Workshop 2012
30. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Interfaces
Interact with the world
Eric Talevich Python Workshop 2012
31. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Modules
Think of a module as a bundle of features. When you import a
module, you load an additional set of features that your program
can use.
>>> import this
>>> type(this)
>>> help(this)
>>> dir(this)
A module may also be called a “package” or “library”, or possibly
“API”. (It’s nuanced.)
Python has many built-in modules. Together, these are called
the “standard library”.
Eric Talevich Python Workshop 2012
32. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Built-in I/O functions
You may already know:
print Write a line to the command-line interface.
>>> print ’Eureka!’
Eureka!
Eric Talevich Python Workshop 2012
33. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Built-in I/O functions
You may already know:
print Write a line to the command-line interface.
>>> print ’Eureka!’
Eureka!
raw input Read a line from the command-line interface.
>>> name = raw input(’Name: ’)
Name: Jonas
>>> print ’My name is’, name
My name is Jonas
Eric Talevich Python Workshop 2012
34. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The sys module
print and raw input are wrappers for standard output and
standard input:
import sys
sys.stdout File handle for writing to the program’s output.
>>> sys.stdout.write(’Eureka!n’)
Eureka!
Eric Talevich Python Workshop 2012
35. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
The sys module
print and raw input are wrappers for standard output and
standard input:
import sys
sys.stdout File handle for writing to the program’s output.
>>> sys.stdout.write(’Eureka!n’)
Eureka!
sys.stdin File handle for reading from the program’s input.
>>> sys.stdout.write(’Name: ’);
... name = sys.stdin.readline()
Name: Jonas
>>> sys.stdout.write(’My name is ’ + name)
My name is Jonas
Eric Talevich Python Workshop 2012
36. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Program arguments
Command-line arguments are stored in sys.argv:
cat hi.py
#!/usr/bin/env python
print ’Hello, Athens!’
Eric Talevich Python Workshop 2012
37. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Program arguments
Command-line arguments are stored in sys.argv:
cat hi.py
#!/usr/bin/env python
print ’Hello, Athens!’
echo ’Some text’ > example.txt
Eric Talevich Python Workshop 2012
38. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
Program arguments
Command-line arguments are stored in sys.argv:
cat hi.py
#!/usr/bin/env python
print ’Hello, Athens!’
echo ’Some text’ > example.txt
python hi.py example.txt
>>> import sys
>>> print sys.argv
[’hi.py’, ’example.txt’]
Eric Talevich Python Workshop 2012
39. Getting started Data structures
How to design programs Algorithms
Python concepts & party tricks Interfaces
More types of interfaces
Pipelines (sys.stdin/stdout/stderr)
API — calling functions from other programs & libraries
IPC — inter-process communication (shm, subprocess)
GUI widgets
Web forms & Javascript events
(Don’t worry about the details here. Just keep this stuff separate
from the main algorithm if you encounter it.)
Eric Talevich Python Workshop 2012
40. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
What is a file?
Consider:
A local file larger than available RAM
Reading data over an internet connection
Problem: Data can’t be viewed all at once
Solution: Retrieve bytes on demand
Eric Talevich Python Workshop 2012
41. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
File handles
A handle points to a location in a byte stream (e.g. the first byte
of the file to be read/written).
>>> myfile = open(’example.txt’)
>>> print myfile.read()
>>> myfile.seek(0)
>>> print myfile.readlines()
>>> myfile.close()
Eric Talevich Python Workshop 2012
42. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
File-like objects
Text (ASCII or Unicode) file on disk
Binary file on disk
Standard input, output, error
Devices, pretty much everything else on Unix
Network connection
Memory map (inter-process communication)
Any Python object supporting the right methods (e.g.
StringIO)
Eric Talevich Python Workshop 2012
43. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Features of Python file objects
Modes:
infile = open(myfile, ’r’)
r, w — read, write
b — binary, to keep Windows from clobbering CR/LF bytes
U — Unicode
Iteration:
for line in infile:
print line.split()
Eric Talevich Python Workshop 2012
44. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
another short
Break
Eric Talevich Python Workshop 2012
45. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Iteration
Iterable objects “know” how they can be looped over.
Python has functions that operate on each item in an iterable:
“for” loop: for x in iterable : ...
zip: for left , right in zip ( iter1 , iter2 ): ...
enumerate: for index , x in enumerate( iterable ): ...
List comprehension: [x ∗ x for x in range(20) if x % 2 == 0]
Eric Talevich Python Workshop 2012
46. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Example: Counting words in a file
Count the words in a file, and print a table sorted by
word frequency.
Let’s expand the wordcount function into a complete script.
Separate algorithms from interfaces
Don’t do any I/O inside wordcount.
Independent output formatting
Use a separate function to print the dictionary wordcount
produces.
Flexible file input
Take a file name as a program argument, or read from
standard input.
Eric Talevich Python Workshop 2012
47. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Enhancing wordcount
1 Read from an open file handle, not a string
Don’t worry about opening or closing it here:
def count words(infile): ...
Eric Talevich Python Workshop 2012
48. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Enhancing wordcount
1 Read from an open file handle, not a string
Don’t worry about opening or closing it here:
def count words(infile): ...
2 Remove punctuation, ignore case when counting words
str.strip and str.lower will work — but could make ’’
Eric Talevich Python Workshop 2012
49. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Enhancing wordcount
1 Read from an open file handle, not a string
Don’t worry about opening or closing it here:
def count words(infile): ...
2 Remove punctuation, ignore case when counting words
str.strip and str.lower will work — but could make ’’
3 Save a line of code with collections.defaultdict
Write what we want more directly:
>>> counts = collections.defaultdict(int)
>>> counts[’new’]
0
Eric Talevich Python Workshop 2012
50. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
import c o l l e c t i o n s
def c o u n t w o r d s ( i n f i l e ) :
””” Count o c c u r r e n c e s o f e a c h word i n i n f i l e .
I n p u t : F i l e h a n d l e open f o r r e a d i n g
Output : d i c t o f { s t r i n g : i n t e g e r }
Example : ( i n f i l e c o n t a i n s ” y e s no y e s no maybe ” )
>>> c o u n t w o r d s ( i n f i l e )
{ ’ maybe ’ : 1 , ’ y e s ’ : 2 , ’ no ’ : 2}
”””
w counts = c o l l e c t i o n s . d e f a u l t d i c t ( i n t )
for l i n e in i n f i l e :
f o r word i n l i n e . s p l i t ( ) :
# I g n o r e c a s e and a d j a c e n t p u n c t u a t i o n
word = word . s t r i p ( ’ ,.;:?! -()" ’ ’ ) . l o w e r ( )
w c o u n t s [ word ] += 1
return w counts
Eric Talevich Python Workshop 2012
51. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Output formatting
Given the dictionary produced by count words . . .
1 Sort entries by counts, in descending order
Use the key argument to select values for comparison:
>>> pairs = [(’one’,1), (’three’,3), (’two’,2)]
>>> select second = lambda x: x[1]
>>> pairs.sort(key=select second); print pairs
[(’one’, 1), (’two’, 2), (’three’, 3)]
Eric Talevich Python Workshop 2012
52. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Output formatting
Given the dictionary produced by count words . . .
1 Sort entries by counts, in descending order
Use the key argument to select values for comparison:
>>> pairs = [(’one’,1), (’three’,3), (’two’,2)]
>>> select second = lambda x: x[1]
>>> pairs.sort(key=select second); print pairs
[(’one’, 1), (’two’, 2), (’three’, 3)]
2 Justify the printed words in a fixed-with column
Use the length of the longest word as the column width.
>>> words = ’thanks for all the fish’.split()’
>>> max(len(word) for word in words)
6
Eric Talevich Python Workshop 2012
53. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
def p r i n t d i c t i o n a r y ( d c t ) :
””” P r i n t t h e k e y s and v a l u e s i n d c t .
S o r t s i t e m s by d e c r e a s i n g v a l u e ; l i n e s up c o l u m n s .
I n p u t : d i c t w i t h s t r i n g k e y s and any−t y p e v a l u e s
”””
# Width n e e d e d f o r d i s p l a y i n g t h e k e y column
k e y w i d t h = max ( l e n ( k e y ) f o r k e y i n d c t )
k v p a i r s = dct . items ()
# S o r t by t h e s e c o n d i t e m i n t h e p a i r , d e c r e a s i n g
k v p a i r s . s o r t ( k e y=lambda kv : kv [ 1 ] , r e v e r s e=True )
f o r key , v a l u e i n k v p a i r s :
# A l i g n both columns a g a i n s t a s t r i p o f t a b s
p r i n t k e y . r j u s t ( k e y w i d t h ) , ’t’ , v a l u e
Eric Talevich Python Workshop 2012
54. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
File I/O and scaffolding
Let’s put it all together.
1 Document usage at the top of the script
Several ways to view this: pydoc, help, doc
Eric Talevich Python Workshop 2012
55. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
File I/O and scaffolding
Let’s put it all together.
1 Document usage at the top of the script
Several ways to view this: pydoc, help, doc
2 Check the given program arguments
If none: read from standard input
If one: open the file and read it
Otherwise: print a helpful error message
Eric Talevich Python Workshop 2012
56. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
File I/O and scaffolding
Let’s put it all together.
1 Document usage at the top of the script
Several ways to view this: pydoc, help, doc
2 Check the given program arguments
If none: read from standard input
If one: open the file and read it
Otherwise: print a helpful error message
3 Exit with proper Unix return codes
Use sys.exit: 0 means OK, otherwise error
$ python -c ’import sys; sys.exit(1)’ && echo OK
$ python -c ’import sys; sys.exit()’ && echo OK
OK
Eric Talevich Python Workshop 2012
57. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
#! / u s r / b i n / env p y t h o n
””” Count t h e words i n a t e x t f i l e o r str eam , and
p r i n t a t a b l e o f word c o u n t s s o r t e d by f r e q u e n c y .
Usage :
w o r d c o u n t . py [ f i l e n a m e ]
”””
import s y s
import c o l l e c t i o n s
def c o u n t w o r d s ( i n f i l e ) :
...
def p r i n t d i c t i o n a r y ( d c t ) :
...
Eric Talevich Python Workshop 2012
58. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
if name == ’__main__ ’ :
i f l e n ( s y s . a r g v ) == 1 :
# Text s t r e a m i n p u t , e . g . from a p i p e
i n f i l e = sys . stdin
e l i f l e n ( s y s . a r g v ) == 2 :
# Read t e x t from t h e g i v e n f i l e
i n f i l e = open ( s y s . a r g v [ 1 ] , ’r’ )
else :
# Too many a r g u m e n t s ! P r i n t u s a g e & q u i t
sys . exit ( doc )
# Now , do e v e r y t h i n g
word counts = count words ( i n f i l e )
p r i n t d i c t i o n a r y ( word counts )
Eric Talevich Python Workshop 2012
59. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
CSV: Comma Separated Values
Python can read and write spreadsheet files in CSV format. 3
(It’s handy if you don’t have a database set up.)
KEY one three five
two 2 6 10
four 4 12 20
six 6 18 30
Let’s convert this to a dictionary-of-dictionaries in Python — the
outer dictionary is keyed by the row labels (from the KEY column),
and the inner dictionary is the row data, keyed by column label.
3
Conversions seem to be easier in OpenOffice/LibreOffice Calc than in Excel.
Eric Talevich Python Workshop 2012
60. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
# Save t h e p r e v i o u s t a b l e a s ’ m t a b l e . c s v ’
# Here , we c o n v e r t i t t o a d i c t −of −d i c t s
import c s v
i n f i l e = open ( ’mtable .csv ’ )
csvreader = csv . DictReader ( i n f i l e )
t a b l e = {}
fo r rowdata in c s v r e a d e r :
k e y = r o w d a t a . pop ( ’KEY ’ )
t a b l e [ key ] = rowdata
# P r e t t y −p r i n t t a b l e w i t h n i c e l y a l i g n e d rows
from p p r i n t import p p r i n t
pprint ( table )
# { ’ four ’: { ’ f i v e ’: ’20 ’ , ’ one ’ : ’ 4 ’ , ’ t h r e e ’ : ’ 1 2 ’ } ,
# ’ s i x ’: { ’ f i v e ’: ’30 ’ , ’ one ’ : ’ 6 ’ , ’ t h r e e ’ : ’ 1 8 ’ } ,
# ’ two ’ : { ’ f i v e ’ : ’ 1 0 ’ , ’ one ’ : ’ 2 ’ , ’ t h r e e ’ : ’ 6 ’ } }
p r i n t t a b l e [ ’four ’ ] [ ’five ’ ] # ’20 ’
Eric Talevich Python Workshop 2012
61. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Thanks
’Preciate it.
Gracias
Eric Talevich Python Workshop 2012
62. Getting started File-like objects
How to design programs Iteration
Python concepts & party tricks The csv module
Further reading
The official Python tutorial is quite good:
http://docs.python.org/tutorial/index.html
This is the book I recommend for learning Python:
http://learnpythonthehardway.org/
This presentation on Slideshare, and the example script on GitHub:
http://www.slideshare.net/etalevich/
python-workshop-1-uga-bioinformatics
https://gist.github.com/661869
Eric Talevich Python Workshop 2012