Tuesday, November 25, 2014
Word Frequency Counter
This program makes a count of the words on a webpage. The basic outline of the program is as follows:
(1) Use Beautiful Soup to crawl a webpage.
(2) Put words from webpage into list.
(3) Pass this word list into a method that cleans up word list.
(4) Pass this clean word list into method that creates a dictionary with key of word and value of number of times word occurs.
See program below:
(1) Use Beautiful Soup to crawl a webpage.
(2) Put words from webpage into list.
(3) Pass this word list into a method that cleans up word list.
(4) Pass this clean word list into method that creates a dictionary with key of word and value of number of times word occurs.
See program below:
Monday, November 24, 2014
Downloading CSV File From Web
(1) Import necessary library
(2) Create function that passes url of csv file.
(3) Open url
(4) Read url
(5) Convert what is read to a string
(6) Create CSV file.
(7) Open csv file to write.
(8) write read url to csv file
(9) Close opened csv file
Wednesday, November 5, 2014
Tuesday, November 4, 2014
Variable Scope, Another Example
Here is another example of a local variable inside a function that can not be used outside the function.The value area has to be passed to a variable outside the function. I have used a '#' to make the code that does that into a comment and thus we the error that area is not defined.
Variable Scope
In the example below the variable, a , is created outside both functions and can be used by both functions.
In the example below the variable a is created inside a function and only that function can use the variable.
Return Statement
The return statement is used to return a value to the caller of the function. It returns a value that can be used outside the function. See example below.
Here is a similar program where the area value is not returned. Thus I have embedded the print statement within the function get a similar output.
Here is a similar program where the area value is not returned. Thus I have embedded the print statement within the function get a similar output.
Monday, November 3, 2014
Monday, October 20, 2014
== Vs is Statement Comparison
Is there a difference between == and is?
is compares if items being compared are from the same object.
== compares if variables are equal.
is compares if items being compared are from the same object.
== compares if variables are equal.
Module Information
Tuesday, October 14, 2014
Frontend, Backend, where does Python fit?
In simple terms front-end is what you see; backend is how it works.
Front-end
The website is usually a mixture of HTML, CSS and Javascript, which are all controlled by the browser.
Back-end
The backend operation is the web application communicating with the server to make changes and store on a server. Languages like PHP, Ruby, and Python are used in this communication.
Front-end
The website is usually a mixture of HTML, CSS and Javascript, which are all controlled by the browser.
Back-end
The backend operation is the web application communicating with the server to make changes and store on a server. Languages like PHP, Ruby, and Python are used in this communication.
Monday, October 13, 2014
Built-In Python Modules
Math is an example of a built-in Python module. If the math module is not imported first the math functions in Python will not work. See example below.
Creating and Importing Modules
A module can be used to save variables and methods. Modules can then be imported into a method. See example below.
Constructors
A constructor is a function that initializes immediately as soon as the objects is created. See example below.
Update to Market Evaluation Program
An update to the Stock Market Evaluation Program that utilizes Classes and Objects to give some additional information in the form of Strings based on user inputs.
Saturday, October 4, 2014
Thursday, October 2, 2014
Object Oriented Programming
An object contains built in attributes. These attributes can be data and/or methods. Functions associated with an object are referred to as methods.
Before an object can be created, a class must be created. A class is a blueprint for an object.
Many objects can refer to the same class.
See below for two examples of creating a class, and then creating an object.
Before an object can be created, a class must be created. A class is a blueprint for an object.
Many objects can refer to the same class.
See below for two examples of creating a class, and then creating an object.
Tuesday, September 23, 2014
Wednesday, September 10, 2014
Tuesday, September 9, 2014
Subscribe to:
Posts (Atom)