Unit 1: Introduction to Python Flashcards
Who designed Python?
Guido van Rossum
When did Python first appear?
1991
Computer program
Consists of a collection of commands, usually stored in a file (or set of files).
Rather than typing out the commands each time we want to execute them, we simply run the program.
Contrast imperative vs declarative programming
With imperative programming, you tell the compiler what to happen step-by-step.
With declarative programming, you write code that describes what you want, but not necessarily how to get it.
E.g.:
Declarative: “Give us every odd number in this collection”
Imperative: “Step through this collection. Check this item. If item % 2 == 0, add it to the result collection”.
6 Strengths of Python as a programming language
- It’s easy to learn the basics.
- It enables smooth progression from simple to complex programming.
- Widely used.
- Huge number of “packages” are available to support specific types of programming.
- Python language provides convenient constructs for many high-level programming ideas.
- Python strikes a good balance between theoretical elegance and practical utility.
5 Weaknesses of Python as a programming language
- May be too slow or inefficient for certain kinds of applications.
- Some programmers don’t like the use of indentation to specify program structure.
- Python does not keep track of or place restrictions on the type of a variable.
- There are a huge number of different ways to do programming tasks, including very simple ones.
- Python does not enforce modularity (though it does support it). This can potentially lead to maintainability problems, especially in a large system.
Intergrated Development Environment
A software tool that is designed to support the whole process of creating programs, including editing, running, and debugging, and also organising and combining different program components.
2 Advantages of server-based implementation of a programming interface
- The server can either be running locally on the same machine as the browser, or remotely on another machine.
- Multiple different machines (and people) may connect to the same server and have access to the same code, allowing collaborative development.
Literate programming
The purpose, functionality and logic of a program are explained by means of natural language descriptions that are included with the actual source code of the program.
In other words, the executable code of a program is shown with documentation of what it is and how it works.
6 General properties and capabilities of notebook programming environments
- The interface is web-based.
- Code execution and file storage are handled via a server.
- Code cells can be executed either individually one at a time, or all code in the notebook can be executed.
- Code output will display below each code cell after it is run.
- When markdown cells are executed, they are rendered into the format specified by the markdown notations within the cell.
- There are a wide variety of other commands such as: file loading and saving, cutting, pasting, searching, clearing output and restarting.
5 Advantages of notebook-style programming
- Notebooks provide a convenient way of planning and documenting code.
- Because documentation is within the same file as the code, it’s less likely to be forgotten or ignored.
- The division of code into cells is well-suited to a pipeline style of programming, where computational processing and/or data analysis proceeds in a series of steps. This division can make programming easier, since each step is a small and relatively simple part of a larger more complex computation.
- Because program output can be nicely displayed, the notebook can also function as a report that presents and explains the results that have been obtained from the code.
- The ability to include nicely formatted explanations, hyperlinks and images along with the code make notebooks an excellent medium for sharing information, as well as teaching and learning.
3 Disadvantages of notebook programming
- They only provide a limited subset of the system development functionality that is available in advanced non-notebook integrated development environments.
- They do not provide good support for developing large systems that involve many complex components.
- They do not promote a good style of structured programming. This is because the linear execution of small program snippets within a notebook does not motivate attention to code structure and modularity.
Variables
Words in a program’s code that are used to stand in place of some value.
They may be thought of as referring to or naming their value.
Rules for variable names in Python
A variable name can consist of any sequence of letters and digits and can also contain the underscore symbol.
Even though variable names can contain digits, the first symbol cannot be a digit.
Operator
This term typically refers to the most basic types of manipulation, such as mathematical operations.
These are often represented by specific symbols, such as +, *, -, …