Mostrar mensagens com a etiqueta Python. Mostrar todas as mensagens
Mostrar mensagens com a etiqueta Python. Mostrar todas as mensagens
sexta-feira, 24 de agosto de 2012
quarta-feira, 22 de agosto de 2012
A Gentle Introduction to Programming Using Python
- site MIT
- How to Think Lyke a Computer Scientist by Allen Downey, (on-line), (pdf livro). (pdf 2)
Lectures
LEC # TOPICS HANDOUTS AND EXAMPLES 1 Introduction Getting started (PDF)raw_input_example.py (PY)2 Conditionals, loops How to comment code properly (PDF)height_example.py (PY)conditional_examples.py (PY)loop_examples.py (PY)3 Defining functions lecture3.py (PY)functions.py (PY)check_for_vowels.py (PY)4 Strings, lists, list comprehensions string_examples.py (PY)list_examples.py (PY)comprehension_examples.py (PY)Additional Material
Two examples of a rock-paper-scissors program:rps_example1.py (PY)rps_example2.py (PY)How to use while-else loops (suggestion: don't use them at all, but if you do be aware they work differently than you might think):while_else.py (PY)Optional lecture Recursion Recursion notes (PDF)Recursion examples (PY)Optional problems (PDF)Solutions to optional problems (PY)5 Tuples, dictionaries, common Python mistakes tuple_examples.py (PY)Remember that the keys of a dictionary must be immutable objects, but thevalues of a dictionary can be either immutable or mutable objects.Common Python mistakes and misconceptions (PDF)6 Classes point.py (PY) 7 More about classes wheel.py (PY) 8 Inheritance inheritance_examples.py (PY) 2. Built-in Functions
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.
quinta-feira, 16 de agosto de 2012
Python - Glossário
algorithm: A general process for solving a category of problems.
bug: An error in a program.
compile: To translate a program written in a high-level language into a low-level language all at once, in preparation for later execution.
debugging: The process of finding and removing any of the three kinds of program-ming errors.
executable: Another name for object code that is ready to be executed.
exception: An error that is detected while the program is running.
formal language: Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are formal languages.
high-level language: A programming language like Python that is designed to be easy for humans to read and write.
interactive mode: A way of using the Python interpreter by typing commands and expressions at the prompt.
interpret: To execute a program in a high-level language by translating it one line at a time.
low-level language: A programming language that is designed to be easy for a computer to execute; also called “machine language” or “assembly language.”
natural language: Any one of the languages that people speak that evolved naturally.
object code: The output of the compiler after it translates the program.
parse: To examine a program and analyze the syntactic structure.
portability: Aproperty of a program that can run on more than one kind of computer.
print statement: An instruction that causes the Python interpreter to display a value on the screen.
problem solving: The process of formulating a problem, finding a solution, and expressing the solution.
program: A set of instructions that specifies a computation.
prompt: Characters displayed by the interpreter to indicate that it is ready to take input from the user.
script: A program stored in a file (usually one that will be interpreted).
script mode: A way of using the Python interpreter to read and execute statements in a script.
semantics: The meaning of a program.
semantic error: An error in a program that makes it do something other than what the programmer intended.
source code: A program in a high-level language before being compiled.
syntax: The structure of a program.
syntax error: An error in a program that makes it impossible to parse (and therefore impossible to interpret).
token: One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.
exception: An error that is detected while the program is running.
formal language: Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are formal languages.
high-level language: A programming language like Python that is designed to be easy for humans to read and write.
interactive mode: A way of using the Python interpreter by typing commands and expressions at the prompt.
interpret: To execute a program in a high-level language by translating it one line at a time.
low-level language: A programming language that is designed to be easy for a computer to execute; also called “machine language” or “assembly language.”
natural language: Any one of the languages that people speak that evolved naturally.
object code: The output of the compiler after it translates the program.
parse: To examine a program and analyze the syntactic structure.
portability: Aproperty of a program that can run on more than one kind of computer.
print statement: An instruction that causes the Python interpreter to display a value on the screen.
problem solving: The process of formulating a problem, finding a solution, and expressing the solution.
program: A set of instructions that specifies a computation.
prompt: Characters displayed by the interpreter to indicate that it is ready to take input from the user.
script: A program stored in a file (usually one that will be interpreted).
script mode: A way of using the Python interpreter to read and execute statements in a script.
semantics: The meaning of a program.
semantic error: An error in a program that makes it do something other than what the programmer intended.
source code: A program in a high-level language before being compiled.
syntax: The structure of a program.
syntax error: An error in a program that makes it impossible to parse (and therefore impossible to interpret).
token: One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language.
assignment: A statement that assigns a value to a variable.
comment: Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.
concatenate: To join two operands end-to-end.
evaluate: To simplify an expression by performing the operations in order to yield a single value.
expression: A combination of variables, operators, and values that represents a single result value.
floating-point: A type that represents numbers with fractional parts.
floor division: The operation that divides two numbers and chops off the fraction part.
integer: A type that represents whole numbers.
keyword: A reserved word that is used by the compiler to parse a program; you cannot use keywords like if, def, and while as variable names.
operand: One of the values on which an operator operates.
operator: A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
rules of precedence: The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.
state diagram: A graphical representation of a set of variables and the values they refer to.
statement: A section of code that represents a command or action. So far, the statements we have seen are assignments and print statements.
string: A type that represents sequences of characters.
type: A category of values. The types we have seen so far are integers (type int), floating-point numbers (type float), and strings (type str).
value: One of the basic units of data, like a number or string, that a program manipulates.
variable: A name that refers to a value.
body: The sequence of statements inside a function definition.
composition: Using an expression as part of a larger expression, or a statement as part of a larger statement.
dot notation: The syntax for calling a function in another module by specifying the module name followed by a dot (period) and the function name.
flow of execution: The order in which statements are executed during a program run.
frame: A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function.
fruitful function: A function that returns a value.
function: A named sequence of statements that performs some useful operation. Functions may or may not take arguments and may or may not produce a result.
function call: A statement that executes a function. It consists of the function name followed by an argument list.
function definition: A statement that creates a new function, specifying its name, parameters, and the statements it executes.
function object: A value created by a function definition. The name of the function is a variable that refers to a function object.
header: The first line of a function definition.
import statement: A statement that reads a module file and creates a module object.
local variable: Avariable defined inside a function. Alocal variable can only be used inside its function.
module: A file that contains a collection of related functions and other definitions.
module object: A value created by an import statement that provides access to the values defined in a module.
parameter: Anameused inside a function to refer to the value passed as an argument.
return value: The result of a function. If a function call is used as an expression, the return value is the value of the expression.
stack diagram: A graphical representation of a stack of functions, their variables, and the values they refer to.
traceback: A list of the functions that are executing, printed when an exception occurs.
void function: A function that doesn’t return a value.
4 - Case Study: Interface Design
development plan: A process for writing programs.
docstring: A string that appears in a function definition to document the function’s interface.
encapsulation: The process of transforming a sequence of statements into a function definition.
generalization: The process of replacing something unnecessarily specific (like a number) with something appropriately general (like a variable or parameter).
instance: A member of a set. The TurtleWorld in this chapter is a member of the set of TurtleWorlds.
interface: Adescription of howto use a function, including the nameand descriptions of the arguments and return value.
keyword argument: An argument that includes the name of the parameter as a “keyword.”
loop: A part of a program that can execute repeatedly.
postcondition: A requirement that should be satisfied by the function before it ends.
precondition: A requirement that should be satisfied by the caller before a function starts.
guardian: Aprogramming pattern that uses a conditional statement to check for and handle circumstances that might cause an error.
incremental development: A program development plan intended to avoid debugging by adding and testing only a small amount of code at a time.
None: Aspecial value returned by functions that have no return statement or a return statement without an argument.
scaffolding: Code that is used during program development but is not part of the final version.
temporary variable: A variable used to store an intermediate value in a complex calculation.
increment: An update that increases the value of a variable (often by one).
infinite loop: A loop in which the terminating condition is never satisfied.
initialize: An assignment that gives an initial value to a variable that will be updated.
iteration: Repeated execution of a set of statements using either a recursive function call or a loop.
multiple assignment: Making more than one assignment to the same variable during the execution of a program.
update: An assignment where the new value of the variable depends on the old.
.
segunda-feira, 13 de agosto de 2012
Python - Introduction to Computer Science and Progamming
MIT
- References
- Lectures:
- Lecture 1: Introduction to 6.00
- Topics covered: Purposes of the course, declarative and imperative knowledge, flow of control, algorithms, fixed program and stored program computers, termination conditions, interpretation, compilation, syntax, static semantics, semantics, and types of errors.
- Lecture slides (PDF)
- Lecture 2: Core Elements of a Program
- Topics covered: IDLE, types of objects, operators, overloading, commands, variables, assignment, input, straight line and branching programs, looping constructs, turing completeness (w), conditionals, nesting.
- Lecture code handout (PDF) (PY)
- Recitation 1: Introduction to Coding Concepts
- Topics covered: Syntax, semantics, object types, comparison, loops, coding.
- Lecture 3: Problem Solving
- Topics covered: Termination, decrementing functions, exhaustive enumeration, brute force, while loop, for loop, approximation, specifications, bisection search.
- Lecture code handout (PDF) (PY)
- Loops. An Introduction to Python.
- Lecture 4: Machine Interpretation of a Program
- Topics covered: Decomposition, module, function, abstraction, formal parameter, actual parameter, argument, assert, scope, mapping, stack, last in first out, LIFO, strings, slicing.
- Lecture code handout (PDF) (PY)
- Recitation 2: Loops, Tuples, Strings and Functions
- Topics covered: Loops, tuples, concatenating tuples and strings, string operations, immutability, range function, slicing, types of data structures, decrementing function, global and local variables, global keepers.
- Lecture 5: Objects in Python
- Topics covered: Tuples, lists, dictionaries, methods, identifiers, modifying objects, aliasing, mutability.
- Further Study
- 8. Lists. How to Think Like a Computer Scientist.
- 9. Tuples. How to Think Like a Computer Scientist.
- 10. Dictionaries. How to Think Like a Computer Scientist.
- 5.1 More on Lists. he Python Tutorial.
- 5.3 Tuples as Sequences. The Python Tutorial.
- 5.5 Dictionaries. The Python Tutorial.
- Lecture 6: Recursion
- Topics covered: Dictionaries, modular abstraction, divide and conquer, recursion, tower of Hanoi, base case, Fibonacci sequence.
- Recitation 3: Lists and their Elements, Sorting, and Recursion
- Topics covered: Tuples, lists, iteration, list elements, sorting lists, mutability, keys, dictionaries, chain method, recursion, base case, Tower of Hanoi (w).
- Further Readings:
- 4.9 Recursion. How to Think Like a Computer Scientist.
- Recursion. An Introduction to Python.
- Comparing Recursion and Looping. An Introduction to Python.
- Lecture 7: Debugging
- Topics covered: Binary, float, floating point, approximations, debugging, runtime error.
- Further Readings
- 8. Errors and Exceptions. Python v2.7.2 Documentation.
- Appendix A: Debugging. How to Think Like a Computer Scientist.
- Lecture 8: Efficiency and Order of Growth
- Topics covered: Efficiency, problem reduction, RAM, best case, worst case, expected case, growth, exponential growth, polynomial growth, logarithmic growth, global variables.
- Lecture 9: Memory and Search Methods
- Topics covered: Memory, storage, indirection, sorting.
Subscrever:
Mensagens (Atom)