Python is an interpreted, object-oriented programming language that is easy to read, write, and learn. It is ranked among the top 10 languages by popularity according to TIOBE and is widely used on GitHub. The Python logo depicts a snake to represent the Pythonidae family. The language emphasizes readability and uses English keywords frequently.
This document discusses looking beyond PHP to improve web development skills. It recommends mastering PHP fundamentals first before exploring other languages and tools. Examples given include learning JavaScript, using tools like Twig or Jinja templates, learning from code in other languages like Python, and understanding documentation standards beyond PHP like PEP and PSR. The overall message is for developers to remain curious, passionate and willing to learn from others outside of PHP.
What We Talk About When We Talk About Coding (Open Source Bridge 6/21)Zoe Landon
Technology is a language all its own, and open source is no exception. But as more people jump into the world of programming, they can be quickly overwhelmed by the volume of jargon. How, then, do we explain powerful technologies without misleading people? It takes empathy, clever language, and a bit of Shakespeare.
This document provides tips for keeping a Plone site lean and optimized for small budgets and resources. Some key recommendations include reducing unnecessary content types and products, following standards, isolating complexity, prioritizing memory for hardware, using caching services like Cloudflare, and protecting against malicious bots and crawlers. The overall message is that a simple, flexible design focused on essentials can keep a Plone site performing well even with limited funds.
Python was created in 1990 by Guido van Rossum as a hobby project. It is a highly portable, interpreted programming language that is designed to be easy to learn and read. Python code tends to be shorter and more readable than comparable code in other languages like C or Java due to its clear syntax and use of whitespace.
Technology So Easy Your Lawyer Could Do It (OSCON 5/18)Zoe Landon
Technology is a language all its own, and open source is no exception. But as more people jump into the world of programming, they can be quickly overwhelmed by the volume of jargon. How, then, do we explain powerful technologies without misleading people? It takes empathy, clever language, and a bit of Shakespeare.
Simple is better than complex. ~私がPythonを愛する理由~cocodrips
This document discusses principles of programming language design from several languages including Python, Perl, and Ruby. It includes the "Zen of Python" which lists principles like "Simple is better than complex" and "Explicit is better than implicit". It also provides examples of code written in different styles and recommends books and articles about language design.
This document provides an introduction to programming by outlining what programming is and the process involved. It explains that programming involves breaking tasks down into small, precise steps that a computer can understand. This is because computers are very limited in their abilities and need complete, detailed instructions. The document also discusses who might be suited to programming, noting it helps to be logical, patient, and enjoy intellectual challenges. It concludes by describing the typical programming process of writing code, compiling it, running it, debugging any issues, and repeating until the program is complete.
This document discusses the Zen of Python philosophy and PEP 8 style guide for writing Python code. It begins by introducing the author and their background. It then explains how to view the Zen of Python principles by importing the "this" module. Several of the Zen principles are listed and explained. The document continues by covering PEP 8 guidelines for indentation, whitespace, comments and other stylistic choices. It provides examples of preferred versus non-preferred coding styles. It concludes by mentioning tools for linting and formatting Python code and provides additional resources for learning more.
Python - The Good, The Bad and The ugly Eran Shlomo
- The document provides an overview of Python from the perspective of the author, including pros and cons.
- Some key advantages mentioned are that Python has a very large ecosystem and library support, is easy to read and learn syntax-wise, and is a leader in machine learning development.
- Disadvantages include slow performance compared to compiled languages, weak support for mobile and browsers, challenges around versioning and packaging, and dynamic typing leading to potential runtime errors.
- The author emphasizes sticking to PEP 8 coding standards and using tools like IDEs, pylint, and PEP 20 ("The Zen of Python") to help address Python's downsides.
The document summarizes a presentation about Python 3 for beginners. It introduces Python, discusses its history and why it's useful. It then provides instructions on installing Python 3 in Ubuntu and recommends documentation resources. The document demonstrates basic Python code like printing strings and variables. It emphasizes indentation and discusses some things to watch out for in Python.
The document discusses email accessibility and provides tips for making emails accessible to all users. It explains that accessibility means emails can be used by everyone regardless of their tools or abilities. True accessibility means emails work on all clients, have a plain text version, clear messages, and a readable design. It also discusses using semantic HTML, avoiding tables, and implementing ARIA roles to help screen readers understand an email's structure and meaning.
This document provides tips and guidance for giving talks. It discusses choosing a topic, designing slides, delivering content, and finishing the talk. Key recommendations include making the first slide engaging, practicing with a microphone, staying passionate, highlighting code samples, and making feedback easy for the audience. The document emphasizes keeping content concise and focused on the speaker's perspective to best engage attendees.
This document provides an introduction to programming by explaining what programming is and whether it is the right career choice. It defines programming as breaking tasks down into small, step-by-step instructions that a computer can understand. It notes that while humans can perform tasks intuitively, computers are very limited and need precise, complete instructions. Therefore, programmers must learn to think differently by decomposing problems in a way that accounts for a computer's capabilities and limitations. Overall, the document aims to give readers a basic understanding of the nature of programming to help them decide if it aligns with their interests and skills.
Inheritance Versus Roles - The In-Depth VersionCurtis Poe
This is the paper to accompany my slides explaining what's wrong with inheritance and how traits (roles) help to solve these issues: http://www.slideshare.net/Ovid/inheritance-versus-roles
A dispute on probably the most controversial feature in ES2016 leads us back to age old questions at the base of the most common practices of the development universe.
Do the “sacred laws” still apply?
jsDay 2016 closing keynote (http://2016.jsday.it/talk/a-class-action/)
There's an old joke that goes, “The two hardest things in programming are cache invalidation, naming things, and off-by-one errors.” In this talk, we'll discuss the subtle art of naming things – a practice we do every day but rarely talk about.
The instructor discusses common errors that students may encounter when programming with Karel such as infinite loops and off-by-one errors. He explains what comments are and how they are used in code to help other programmers understand the program. He demonstrates an example of an off-by-one error in a Karel program that lays down beepers in a row and how adding a final beeper placement fixes the bug. The instructor emphasizes writing programs with comments to explain the purpose and encourage students to ask questions.
This document provides a list of 40 words and phrases to avoid using in IELTS examinations. Some examples included are "and/or", "basically", "due to the fact that", "he/she", "literally", "lots", "nature", "orientate", "per", "point in time", "previous", "suppose to", and "utilize". The document recommends replacing vague or redundant terms with more precise language and dropping needless words to improve clarity and formality.
The document provides advice for introducing XP (eXtreme Programming) practices to colleagues, bosses, and customers who may not be familiar with or supportive of XP. It suggests starting small with XP practices, introducing new concepts gradually, looking for opportunities to demonstrate benefits, focusing on the biggest problems, and being willing to change and improve processes over time.
Rust is a systems programming language that provides memory safety without using a garbage collector. It achieves memory safety through rules of ownership, borrowing, and lifetimes that are checked at compile time. These rules prevent common memory bugs like memory leaks, dangling pointers, and use-after-free errors that are common in C and C++.
The document discusses rendering dropdown menus in the content process. It notes there are performance, styling, and event behavior issues with the current e10s-select approach. An alternative approach called content-select would render the dropdown as normal content in the content process to achieve better performance, stronger style support, and more accurate events without these issues. It provides an example of complex styling that can be applied to options in the dropdown.
The document discusses Rust's ownership system and borrowing. It explains that variables own the memory for their values, and when a variable goes out of scope that memory is returned. References allow borrowing values without transferring ownership. References must live shorter than the values they reference. Mutable references also allow changing borrowed values, but there can only be one mutable reference at a time.
The document discusses concurrency in C++ and the use of std::async and std::future. It recommends preferring task-based programming over thread-based due to easier management. It notes that the default launch policy for std::async allows asynchronous or synchronous execution, creating uncertainty. It advises specifying std::launch::async if asynchronicity is essential to ensure concurrent execution and avoid issues with thread-local variables and timeout-based waits.
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
If you want to manipulate mozSettings with JavaScript, you can reference to Settings API on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Settings_API).
But if you want to manipulate it with C++, we can only reference to the codebase of Gecko. Now, let me show you some example.
The document describes how Necko handles data URLs in Firefox. It discusses:
1. The data URL protocol syntax and how Necko parses data URLs to determine the MIME type, encoding, and data.
2. How Necko gets the protocol handler for data URLs and uses the nsDataHandler to create an nsDataChannel for the URL.
3. How the nsDataChannel establishes a listener chain with the nsInputStreamPump and nsHtml5StreamParser/Listener to read the data in chunks and parse the HTML content.
4. The states the nsInputStreamPump goes through - START, TRANSFER, STOP - to read the data from the nsDataChannel and
The document discusses protocol handlers in Gecko. It explains that protocol handlers allow Gecko to interact with different URI schemes like http, ftp, file etc. It provides an overview of how the awesome bar, browser UI, DocShell and Necko components work together to handle protocol requests from inputting a URL in the awesome bar to creating a channel and loading content. It also briefly introduces channels and stream listeners in Necko which are used for asynchronous loading of content.
This document provides an introduction to Linux, including what it is, some popular Linux distributions like Ubuntu, and reasons why one might use Linux instead of Windows. It notes that while Linux's desktop market share is still lower than Windows, it is widely used in servers, Android devices, and supercomputers. The document discusses how to install Ubuntu and some basic features and software available in Ubuntu. It argues that Linux is more secure, customizable, and liberating for users compared to Windows. However, it acknowledges Linux still lacks versions of some essential software and may not support all hardware.
VP8 is an open source video codec developed by On2 Technologies and acquired by Google in 2010. It is designed for web-based video applications with a focus on low bandwidth and support for heterogeneous hardware. VP8 uses intra-frame and inter-frame prediction, 4x4 transform coding with an adaptive loop filter to reduce artifacts, and entropy coding with adaptive probability distributions. It achieves good quality at low bitrates and supports parallel processing for improved decoding performance on modern hardware.
This document describes an algorithm for determining if two trees are isomorphic by hashing the trees. It hashes each subtree and sorts the hashes to get a unique representation of the tree. It recursively hashes subtrees from leaves to root. The hash of the whole tree represents the tree and trees are isomorphic if they have the same hash value. The time complexity is O(N log N) where N is the number of vertices. Pseudocode and examples are provided.
The document describes Dinic's algorithm for finding the maximum flow in a flow network. It involves building a level graph of the network and finding blocking flows by finding augmenting paths from the source to the sink, then identifying bottlenecks on those paths and pushing flow along reverse paths from the bottlenecks to the sink in an iterative manner until no more augmenting paths exist. An example applying these steps on a sample network is provided to illustrate the algorithm.
The document discusses graph traversal algorithms depth-first search (DFS) and breadth-first search (BFS). It provides examples of how DFS and BFS traverse graphs using a stack and queue respectively. Pseudocode for DFS and BFS algorithms is presented. The time complexity of both algorithms is O(V+E) where V is the number of nodes and E is the number of edges. Examples of DFS and BFS traversing a mouse maze are also shown.
The document describes the closest pair problem and an algorithm to solve it in 3 steps:
1. Sort the points by their x-coordinates
2. Recursively divide the points into halves and solve the sub-problems
3. Merge the solutions of the sub-problems and consider additional point pairs near the dividing line to find the overall minimum distance.
The document describes the bubble sort, merge sort, and quick sort algorithms. Bubble sort has a time complexity of O(n^2) as it may require up to n^2 comparisons in the worst case. Merge sort has a time complexity of O(nlogn) as it divides the list into halves recursively until single elements remain, then merges the sorted halves. Quick sort also has O(nlogn) time as it partitions the list around a pivot element, recursively sorts sublists, and merges the results.
This is an introduction to Google Productivity Tools for office and personal use in a Your Skill Boost Masterclass by the Excellence Foundation for South Sudan on Saturday 13 and Sunday 14 July 2024. The PDF talks about various Google services like Google search, Google maps, Android OS, YouTube, and desktop applications.
How to Make a Field Storable in Odoo 17 - Odoo SlidesCeline George
Let’s discuss about how to make a field in Odoo model as a storable. For that, a module for College management has been created in which there is a model to store the the Student details.
How To Sell Hamster Kombat Coin In Pre-marketSikandar Ali
How To Sell Hamster Kombat Coin In Pre Market
When you need to promote a cryptocurrency like Hamster Kombat Coin earlier than it officially hits the market, you want to connect to ability shoppers in locations wherein early trading occurs. Here’s how you can do it:
Make a message that explains why Hamster Kombat Coin is extremely good and why people have to spend money on it. Talk approximately its cool functions, the network in the back of it, or its destiny plans.
Search for cryptocurrency boards, social media groups (like Discord or Telegram), or special pre-market buying and selling structures wherein new crypto cash are traded. You can search for forums or companies that focus on new or lesser-acknowledged coins.
Join the Right Communities: If you are no longer already a member, be a part of those groups. Be active, share helpful statistics, and display which you recognize your stuff.
Post Your Offer: Once you experience comfortable and feature come to be a acquainted face, put up your offer to sell Hamster Kombat Coin. Be honest about how plenty you have got and the price you need.
Be short to reply to any questions capability customers may have. They may need to realize how the coin works, its destiny capability, or technical details. Make positive you have got the answers equipped.
Talk without delay with involved customers to agree on a charge and finalize the sale. Make sure both facets apprehend how the coins and money could be exchanged.
How To Sell Hamster Kombat Coin In Pre Market
Once everything is settled, move beforehand with the transaction as deliberate. You might switch the cash immediately or use a provider to assist.
Stay in Touch: After the sale, check in with the customer to ensure they were given the coins. If viable, leave feedback in the network to expose you’re truthful.
How To Sell Hamster Kombat Coin In Pre Market
When you need to promote a cryptocurrency like Hamster Kombat Coin earlier than it officially hits the market, you want to connect to ability shoppers in locations wherein early trading occurs. Here’s how you can do it:
Make a message that explains why Hamster Kombat Coin is extremely good and why people have to spend money on it. Talk approximately its cool functions, the network in the back of it, or its destiny plans.
Search for cryptocurrency boards, social media groups (like Discord or Telegram), or special pre-market buying and selling structures wherein new crypto cash are traded. You can search for forums or companies that focus on new or lesser-acknowledged coins.
Join the Right Communities: If you are no longer already a member, be a part of those groups. Be active, share helpful statistics, and display which you recognize your stuff.
Post Your Offer: Once you experience comfortable and feature come to be a acquainted face, put up your offer to sell Hamster Kombat Coin. Be honest about how plenty you have got and the price you need.
Hamster kombat free money Withdraw Easy free $500 mo
Demonstration module in Odoo 17 - Odoo 17 SlidesCeline George
In Odoo, a module represents a unit of functionality that can be added to the Odoo system to extend its features or customize its behavior. Each module typically consists of various components, such as models, views, controllers, security rules, data files, and more. Lets dive into the structure of a module in Odoo 17
Open Source and AI - ByWater Closing Keynote Presentation.pdfJessica Zairo
ByWater Solutions, a leader in open-source library software, will discuss the future of open-source AI Models and Retrieval-Augmented Generation (RAGs). Discover how these cutting-edge technologies can transform information access and management in special libraries. Dive into the open-source world, where transparency and collaboration drive innovation, and learn how these can enhance the precision and efficiency of information retrieval.
This session will highlight practical applications and showcase how open-source solutions can empower your library's growth.
Plato and Aristotle's Views on Poetry by V.Jesinthal Maryjessintv
PPT on Plato and Aristotle's Views on Poetry prepared by Mrs.V.Jesinthal Mary, Dept of English and Foreign Languages(EFL),SRMIST Science and Humanities ,Ramapuram,Chennai-600089
6. Top Language in TIOBE
Position
May 2013
Position
May 2012
Delta in
Position
Programming Language
1
2
3
4
5
6
7
8
9
10
1
2
4
3
5
6
7
8
9
11
=
=
↑
↓
=
=
=
=
=
↑
C
Java
Objective-C
C++
C#
PHP
Visual Basic
Python
Perl
Ruby
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
7. Top Languages in Github
Javascript
21%
Ruby
12%
Java
8%
Python
8%
Shell
8%
PHP
7%
C
6%
C++
5%
Perl
4%
Objective-C
3%
0%
5%
10%
15%
20%
25%
https://github.com/languages
8. Top Languages in Github
Javascript
21%
Ruby
12%
Java
8%
Python
8%
Shell
8%
PHP
7%
C
6%
C++
5%
Perl
4%
Objective-C
3%
0%
5%
10%
15%
20%
25%
https://github.com/languages
29. Zen of Python
one
There
temptation to guess. and refuse
In --obviousbe
Unless
Errors
Althoughcasesbetter
breakis betternever pass Peters
Specialfacebetter may beats
ReadabilityPython,tonested.
Sparse explicitly silenced.
FlatZenshould“”ambiguity,silently.
Complexispracticality dense. obvious
Simpleshouldofaren'tthanit. enough
Explicitisrules. than complex.
Beautifulisthisthanthan implicit.the at
The importbetterone--docomplicated. only
>>>thethe-iccounts.byspecialpurity. to
$ pythonofisbetterthanTimugly.
that way
not preferably
be
first
one
There
temptation to way
In --obvious guess. and preferably
Unless casesyou're
Errors betternever Dutch.refuse
Althoughisrules. may beats
breakisfacebetter topass Peters
Specialexplicitlythan dense.
ReadabilityPython,silenced.
Sparseunlessofaren'tnested. obvious
FlatZenshouldbeambiguity,silently.
Complexisthatbetter thanit. enough
Simpleshouldcounts.than implicit.the at
Explicitofbetterone-- complex.
Beautifulpracticalitydocomplicated. only
The importisbetterthanTimugly.
>>>thetheisthisthanbyspecialpurity. to
not be
Now
first
one is cases than
There
temptationrules.
In --obvious way may and preferably
Unless betterguess. beats
Errors better never Dutch.refuse
Althoughisbetterone-- dense.
breakisfacetoyou're pass Peters
Specialexplicitly tonested.
Readabilitybetterthan complex.
Sparseunlessofaren'tthanit. obvious
FlatZenshouldbethannever.silently.
Complexisthatbetterthan implicit.the
Simpleshouldcounts.bydocomplicated. at
Explicitofisbettersilenced. enough only
Beautifulpracticalityspecialpurity. to
ThethetheisPython,thanTimugly.
ambiguity, be
not
Now
first
one is cases thanmay not preferably
There
temptationbetterone-- andsilently.
In the better way to beats
Unless face
Errorsunlessofguess. dense.
Althoughbetternever Dutch.refuse
breakisexplicitly silenced.
Specialshould aren'tpassbetter
Readabilitytoyou're nested. obvious
Sparseshouldcounts. thanit. enough
Flat--obviousbethannever.ugly.
Complexisthatbetterthan implicit.the at
Simplethepracticalitydocomplicated. only
Explicitisisbetterthancomplex. than *right*
Beautifulisbetterthanspecialpurity. to
never ambiguity, be
rules. often
is
now.
Now
first
one is cases thanmay not preferably
There
temptationbetterone-- andsilently.
In the better way to beats
Unless face
Errorsunlessofguess. dense.
Althoughbetternever Dutch.refuse
breakisexplicitly silenced.
Specialshould aren'tpassbetter
Readabilitytoyou're nested. obvious
Sparseshouldcounts. thanit. enough
Flat--obviousbethannever.ugly.
Complexisthatbetterthan implicit.the at
Simplethepracticalitydocomplicated. only
Explicitisisbetterthancomplex. than *right*
Beautifulisbetterthanspecialpurity. to
never ambiguity, be
rules. often
is
If
now.
Now
first
one is cases thanoften
There implementation isbetter
temptationrules. may not preferably
In the better way to andhard than
Unless face ofguess. beats
Errorsunlesscounts. Dutch.refuse
Althoughbetternever passit.
breakisexplicitly silenced.
Specialshould aren'tnested. obvious
Readabilitytoyou'renever.silently.
Sparseshouldbetterthandense. enough at
Flat--obviousbethanthan implicit.explain,
Complexispracticality complex.to the only
Simpletheisbetterthandocomplicated. *right*
Explicitisbetterone--specialpurity. to
never is
that ambiguity, be
it's
If
now.
Now
first
one is bad idea. may isbetter
Therea implementation not preferably
temptationrules. to andhard than
In the better way silenced.
Unless faceto guess. beats
Errorsunlessofnever
Althoughisbetterone-- dense.
breakisexplicitly thancomplex.to explain,
Specialshould aren'tDutch.refuse the
Readabilitybetterthandocomplicated.
Sparseshouldcounts. passit. obvious at
Flat--obviousyou're nested. enough only
Complexisthatbethannever.silently. *right*
Simplethepracticalityspecialpurity. to
cases ambiguity, be
betterthanoften
never is
it's
If
now.
Now
first bad idea. may
one is implementation isbetter
Therea better way to noteasy
temptationrules. silenced.
In the faceto guess. andhard than
Unlessunlessofnever
Errorsshouldcounts. Dutch.refuse explain,
Althoughisbetterone-- beats
breakisexplicitly thandense. to the
Specialshould aren'tpassit. obvious
Readabilitybetterthandocomplicated. at
Sparsethethatyou're nested. enough only
Flat--obviousbethannever.silently. *right*
Complexispracticalityspecialpurity. to
cases ambiguity, preferably
betterthanoften
never is
be
it
it's
If
now.
Now is badrules. may
first implementation is preferably
onemay better thanto noteasy
Therea faceidea. silenced.
temptationbetterone-- andhard than
In the explicitlyidea.beats
Unlessunlessofwaythan dense.
Errorsshouldcounts.
Althoughbetterguess. do betterto explain,
breakisshould never Dutch.refuse the
Specialisthat aren'tpassit. obvious at
Readabilitytoyou're nested. enough only
Sparsethepracticalityspecialpurity. *right*
Flat--obviousbethannever.silently. to
benever ambiguity, be
cases is often
a good
Namespacesaare is often
it
it's
If
now.is badrules. may
Now --obvious thanto is
first implementation not be
onemay better way silenced.
There faceidea. idea.andeasy than
temptationbetterone-- beats
In the explicitlythan dense. obvious
Unless should guess. do betterto idea
Errorsunlessofnever Dutch.preferably
Althoughcases aren'tpassit.great explain,
breakashouldcounts.honkingrefuse the at
Specialisthatyou'renever.hardenough only
Readabilitytobeambiguity,silently. *right*
Sparsethepracticalityspecialpurity. to-benever one
good
let's bad good often
Namespacesaareof may
it
it's
If
now.is implementation is
Now --obvious thanto not be
first better way silenced.
onemay faceidea. those!
There explicitlyidea.andeasy than
temptationrules.one-- beats obvious
In thedo that guess. do betterto idea
Unlessunlessofnever Dutch.preferably
Errorsshouldcounts.honkingrefuse explain,
Althoughcases aren'tpassit.great the at
breakathepracticalityspecialpurity. only
Specialshouldyou'renever.hardenough *right*
Readabilitytobeambiguity,silently. to-benever is
more one
>>>
let's bad areof often
Namespacesaidea. may is
it
it's
If
now.is implementation not
Now --obvious thanto and be
first better way silenced.
onemay faceto guess.Dutch.preferably
There explicitlythose! easy than
temptationrules. idea.beats obvious
In thedo that neverhonkingrefuse idea
Unlessunlessgoodone--do betterto explain,
Errorsshouldofaren'tpassit.great the at
Althoughcasesyou'renever.hardenough only
breakathepracticalityspecialpurity. *right*
Specialshouldbeambiguity,silently. to-benever is
more one
35. Python 2.x
Python 3.x
2.7.x is the latest version
under development
more 3-party library
2to3.py
built-in on many OS
more supported unicode
the past in someday
the future in someday
41. Environment
For Windows User,
Download From
http://www.python.org/download/
if you want to launch Python in command line,
add the path of Python binary file into PATH variable.
48. Check Version of Python
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
49. Check Version of Python
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
52. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
53. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
prompt
54. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
prompt
means that your turn!
57. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
58. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
59. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>>
60. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
61. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
‘Hello World’
>>>
62. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
‘Hello World’
>>> x = 100
63. Interactive Shell
Python 2.7.5 (default, May 20 2013,
$ python
23:41:46)
Python 2.7.5 (default, May 20 2013,
[GCC 4.2.1
23:41:46) Compatible Apple LLVM 4.2
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
"license" for more information.
Type "help", "copyright", "credits" or
>>> 1 + 2 + 3
"license" for more information.
6
>>> 1 + 2 + 3
>>> “Hello World”
6
‘Hello World’
>>> “Hello World”
>>> x
‘Hello=World’
100
>>> x = 100
64. Interactive Shell
Python 2.7.5 (default, May 20 2013,
$ python
23:41:46)
Python 2.7.5 (default, May 20 2013,
[GCC 4.2.1
23:41:46) Compatible Apple LLVM 4.2
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
"license" for more information.
Type "help", "copyright", "credits" or
>>> 1 + 2 + 3
"license" for more information.
6
>>> 1 + 2 + 3
>>> “Hello World”
6
‘Hello World’
>>> “Hello World”
>>> x
‘Hello=World’
100
>>> x = 100
y
200
65. Interactive Shell
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
[GCC 4.2.1
23:41:46) Compatible May LLVM 4.2
Python 2.7.5 (default,Apple20 2013,
(clang-425.0.28)] on Apple
[GCC 4.2.1
23:41:46) Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits"
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2or
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>>
"license" for more information.
Type1"help",3"copyright", "credits" or
+ 2 +
6
>>> 1 + 2 + 3
"license" for more information.
6
>>> “Hello+World”
1 + 2
3
‘Hello World’
>>> “Hello World”
6
‘Hello=World’
>>> “Hello World”
x
100
>>> x
‘Hello=World’
y
200
100
>>> x = 100
y
200
66. Interactive Shell
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
[GCC 4.2.1
23:41:46) Compatible May LLVM 4.2
Python 2.7.5 (default,Apple20 2013,
(clang-425.0.28)] on Apple
[GCC 4.2.1
23:41:46) Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits"
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2or
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>>
"license" for more information.
Type1"help",3"copyright", "credits" or
+ 2 +
6
>>> 1 + 2 + 3
"license" for more information.
6
>>> “Hello+World”
1 + 2
3
‘Hello World’
>>> “Hello World”
6
‘Hello=World’
>>> “Hello World”
x
100
>>> x
‘Hello=World’
y
200
100
>>> x = y
y + 100
200
67. Interactive Shell
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
Type "help", "copyright",
[GCC 4.2.1
23:41:46) Compatible May"credits"
Python 2.7.5 (default,Apple20 2013, or
LLVM 4.2
"license"
(clang-425.0.28)] information.
[GCC 4.2.1 Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
6
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
+ 2
‘Hello 2 + 3
6
>>> 1 +World’
"license" for more information.
6
>>> “Hello+World”
x + 2
1 = 100 3
‘Hello=World’
>>> “Hello World”
6
y
200
‘Hello=World’
>>> “Hello World”
x + y
100
300 y
>>> x
‘Hello=World’
200
100
>>> x = y
y + 100
200
68. Interactive Shell
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
Type "help", "copyright",
[GCC 4.2.1
23:41:46) Compatible May"credits"
Python 2.7.5 (default,Apple20 2013, or
LLVM 4.2
"license"
(clang-425.0.28)] information.
[GCC 4.2.1 Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
6
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
+ 2
‘Hello 2 + 3
6
>>> 1 +World’
"license" for more information.
6
>>> “Hello+World”
x + 2
1 = 100 3
‘Hello=World’
>>> “Hello World”
6
y
200
‘Hello=World’
>>> “Hello World”
x + y
100
300 y
>>> x
‘Hello=World’
200
100
>>> for y in range(5):
y + 100
x = i
200
69. Interactive Shell
Type "help", "copyright",
(clang-425.0.28)] on darwin20 2013,
23:41:46)
Python 2.7.5 (default, May"credits" or
$ python
"license"
Type "help", more information.
[GCC 4.2.1 Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python 2.7.5 (default,Apple20 2013, or
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello+World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
x
2 +
6
>>> “Hello+World”
y
x + 200
1 = 100 3
2
‘Hello=World’
>>> “Hello World”
6
x
y + y
200
300 x + y
‘Hello=World’
>>> “Hello World”
100
300 x
>>> for i in
‘Hello=World’range(5):
y
200
100
... x = i
>>> for y in range(5):
y + 100
200
70. Interactive Shell
Type "help", "copyright",
(clang-425.0.28)] on darwin20 2013,
23:41:46)
Python 2.7.5 (default, May"credits" or
$ python
"license"
Type "help", more information.
[GCC 4.2.1 Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python 2.7.5 (default,Apple20 2013, or
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello+World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
x
2 +
6
>>> “Hello+World”
y
x + 200
1 = 100 3
2
‘Hello=World’
>>> “Hello World”
6
x
y + y
200
300 x + y
‘Hello=World’
>>> “Hello World”
100
300 x
>>> for i in
‘Hello=World’range(5):
y
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
71. Interactive Shell
"license"
Type "help", more information.
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 "copyright", 20 2013,
$ python for(default, May"credits" or
>>>
"license"
Type "help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
2
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> "help",3"copyright", "credits"
Type14.2.1 Compatible Apple
(clang-425.0.28)]
[GCC“Hello+World” on darwin LLVM 4.2or
+ 2
‘Hello World’
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
x + 100
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
72. Interactive Shell
>>>
"license"
Typey"help",
(clang-425.0.28)] information.
23:41:46) for moreon darwin
Python=2.7.5 "copyright", 20 2013,
$ python200 (default, May"credits" or
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> 14.2.1 Compatible
Typefor i +World”
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
"help", "copyright", "credits"
+ 2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
73. Interactive Shell
>>>
"license"
Typey"help",
(clang-425.0.28)] information.
23:41:46) for moreon darwin
Python=2.7.5 "copyright", 20 2013,
$ python200 (default, May"credits" or
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> 14.2.1 Compatible
Typefor i +World”
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
"help", "copyright", "credits"
+ 2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
exit()
y + i
200
100
74. Interactive Shell
>>> x + 200
"license"
Typey"help", more information.
(clang-425.0.28)] on darwin
23:41:46)
Python=2.7.5 "copyright", 20 2013,
$ pythony for(default, May"credits" or
300
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>> 14.2.1
"license" +Compatible
(clang-425.0.28)] information.
[GCCfor i for moreon darwin
23:41:46) in3range(5):Apple LLVM 4.2
+ 2
... "help", i
6
>>> 14.2.1+World”
Typefor print"copyright", "credits"
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
+ i Compatible
2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
0
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
1
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
2
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
3
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
4
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
exit()in
i
200
100
$
... x = y in i
>>> for printrange(5):
exit()
y + i
200
100
81. A Python Code
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
9x9table.py
82. script language
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
no specified entry point
86. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
87. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
88. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
and write all statements after it.
89. variable
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
can be used without declaration
90. variable
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
can be used without declaration
91. scope
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
use whitespace to identify scope
92. scope
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
use whitespace to identify scope
166. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
>>> “““Hello
... World!”””
‘HellonWorld!’
>>> x = “““Hello
... World!”””
>>>
167. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
>>> “““Hello
... World!”””
‘HellonWorld!’
>>> x = “““Hello
... World!”””
>>> print x
168. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
... World!”””
>>> “““Hello
‘HellonWorld!’
... World!”””
>>> x = “““Hello
‘HellonWorld!’
... x = “““Hello
>>> World!”””
>>> print x
... World!”””
Hello
>>> print x
World!
>>>
369. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
370. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
371. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
372. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
373. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
374. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
375. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
print i
376. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
print i
...
377. Addition for Loop
skip remaining statement and
continue
continue loop
...
>>> for ifin range(5):
i i == 2:
...
if icontinue
== 2:
...
print i
continue
...
print i
0
...
1
3
4
>>>
393. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
394. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
395. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
print “done”
396. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
print “done”
...
397. Addition for Loop
else
do something after unbroken
loop
...
>>> for i in range(3):
print i
... else:
print i
... else:
print “done”
...
print “done”
0
...
1
2
done
>>>