1 / 139

News Aggregator

News Aggregator.

sally
Download Presentation

News Aggregator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. News Aggregator • A news aggregator refers to a system including software application, webpage or service that collects syndicated content using RSS and other XML feeds from weblogs and mainstream media sites. Aggregators improve upon the time and effort needed to regularly check websites of interest for updates, creating a unique information space or "personal newspaper." An aggregator is able to subscribe to a feed, check for new content at user-determined intervals, and retrieve the content. The content is sometimes described as being "pulled" to the subscriber, as opposed to "pushed" with email or other channels. Unlike recipients of some "pushed" information, the aggregator user can easily unsubscribe from a feed. • Software which allows syndicated news content (such as RSS feeds) to be brought together and displayed.

  2. Introduction of Python For Engr 101 5-Week News Aggregator Module Fall 2010 Instructor: Tao Wang

  3. What is a computer?

  4. Computer Organization

  5. Software / Programs • Computer Programs instruct the CPU which operations it should perform/execute • Programmers write the code for the tasks a computer program performs • But computers only understand binary (1’s and 0’s) • Programmers need a language to write computer code

  6. Types of Programming Languages Low-Level Languages • Machine Languages • CPU instructions are binary strings of 1’s and 0’s [10010000] • Each kind of CPU has different instruction sets • Programs are not portable across CPU’s architectures • Difficult for programmers to read/write • Assembly Languages • Use English-like abbreviations to represent CPU instructions • A bit easier to understand [MOV AL, 42h] • Converted to machine language using an assembler • Still not portable

  7. Types of Programming Languages High-Level Languages • C/C++, Java/C#, Python, Ruby, many more... • These languages abstract hardware implementation details • Provides programmers a logical computer model • Allows programmer to focus on solving problems instead of low-level hardware details • Use English-like keywords and statements to write code • Use a compiler or interpreter that translates code to machine language • Makes code portable across different CPU’s and platforms • Programmer does not have to learn each CPU’s instructions

  8. Compiled vs. Interpreted • Both Compilers and Interpreters translate source code to machine language • Compiled • Must compile program on each target CPU architecture prior to execution. • Interpreted • Code can be directly run on any platform that has an available interpreter

  9. About Python • Designed by Guido van Rossum in late 1980’s • Interpreted programming language • Imperative, Dynamic, and Object-Oriented • Python Programs • are a sequence of instructions written in Python language • interpreter executes the instructions sequentially, in order • programs can take inputs and send data to outputs • programs can process and manipulate data • programs may read and write data to RAM, Hard Drive, ... • First Program • print “Welcome to learning Python.“

  10. PYTHON: LETS BEGIN • The Python Shell (2.6) • You type commands • It does stuff • It converts python to machines instructions and runs them right now

  11. Python as Calculator >> 2 + 2 # add 4 >> 2 * 3 # muliply 6 >> 3**2 # powers 9 >> 12 % 11 #modulo (remainder) 1

  12. Division • Integer division • 1/4 #Integer division, no decimals • 0 • Float division • 1.0/4.0 #float number division • 0.25

  13. Literals, Variables, Data Types,Statements and Expressions

  14. Literals, Data Types Numbers • Integers are natural numbers: ..., -2, -1, 0, 1, 2, ... (32 bits) • Floats contain decimals: 4.5, 67.444443335, 7E2... • Booleans: True, False • Long int’s that exceed 32 bit capacity • Complex numbers: 4.5, 1j * 1j = -1 + 0j Strings • Strings are used to represent words, text, and characters • examples (can use single, double or triple quotes): • “I am learning python.“ • 'hello.'

  15. Variables • Literals are data values that our program use • Data is stored in memory, and we need a way to access it • We use variables to name our data in memory • We can retrieve data by calling the name that refers to it • student_name = “Ben” • print student_name • = is the assignment operator, assigns a data value to a variable

  16. Variables Syntax Rules • Variable names must begin with a letter (uppercase or lowercase) or underscore (_) • * good programming convention: variables should not start with uppercase letters, commonly used for something else • remainder of name can contain letters, (_), and numbers • names may not contain spaces or special characters • names are case sensitive and must not be a reserved python keyword • myVariableandmyvariablerefer to different data

  17. Statements and Expressions • Statement perform a task; do not return a value • x = 2 • y = 3 • print y • Expression return a value • >> x+ y • 5

  18. Expressions (evaluate to values) • Math expressions • >> 10 * 2 + 3 • >> 10 * (2.0 + 3) • Boolean expressions • >> 10 < 2 # False • >> 10 >=10 # True • Combined with logic operators • >> (10<2) or (10==10) • Can combine • >> (a*c+d) > (d*a-c)

  19. Expressions (evaluate to values) • String expressions • >> “hel” + “lo” # ‘hello’ • >> “Hi” * 3 # ‘HiHiHi’ • Operator Precedence • Parentheses • Exponentiation • Multiplication and Division • Addition and Subtraction

  20. Operator Precedence (top-to-bottom)

  21. Data Types • Finding out a data type

  22. Data Types • What if data types don’t match? • STRONG TYPES no automatic conversion (for non number types)

  23. Data Types • Explicit conversion

  24. Python Keywords, User Input

  25. Python Keywords • RESERVED: do not use as variable names

  26. User Input • Create interactive programs by requesting user input

  27. Control Structures

  28. Branching / Conditional Statements • Decision making

  29. if - statement if a < 0: print “a is negative”

  30. if - else

  31. if - elif - else • If one test fails, perform next test

  32. Nested if statements

  33. Modules

  34. Modules • Python Strength: large collection of open source modules • •Modules are collections (packages) of useful (tested) code you can reuse • Common modules: random, math • The modules we use for the project: • urllib, xml

  35. Modules • Python Standard Library (packages included with most python distributions) • http://docs.python.org/library/index.html • PyPI (Python Package Index) • http://pypi.python.org/pypi • repository of optional modules available (11,000+)

  36. Using Modules • Math module contains many useful functions and values: math.sin, math.cos, math.pow, math.sqrt, ... • Using modules:

  37. Getting help • In python interpreter you can get documentation

  38. Control Structures:Repetition, Iteration

  39. Repetition • selection statements (if-elif-else) let us make simple decisions • repeating statements and decisions let us build more complex programs

  40. while

  41. Testing Primeness

  42. break statement • break immediately ends loops • DO NOT overuse; Can be difficult to read/understand logic

  43. Testing Primeness

  44. range(...) • Built in function; produces a sequence (list) • range(0, 3)  [0, 1, 2] • range(3)  [0, 1, 2] • range(1, 3)  [1, 2] • range(1,7,2)  [1, 3, 5]

  45. for • The for loop is used for iteration

  46. continue statement • break and continue work in both while and for loops

  47. Find all primes

  48. while - else

  49. Nesting Control Structures • We can nest control structures (if, while, for) • We can nest many times while … while … while … If … for ... • There is a limit; If you reach it, something is WRONG • Abuse makes code unreadable; Use functions instead... (more in a bit)

  50. Counter-Controlled Loops

More Related