Home
aviestra [entries|archive|friends|userinfo]
aviestra

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

(no subject) [Apr. 26th, 2006|01:15 pm]
http://www.explodedview.tv/articles/psychology.html

To survive as a dot com business, a company’s branding must be their product or service, not their logo.

When developing a web site, careful thought must be given in order to acheive your desired results. Do you want to sell widgets? Then put your widgets where people can see them. Make it easy for your customer to find the widget THEY want right away.

One effective trend in design is to minimize the company identification. A logo may be only 1/2 inch tall located in the upper left hand corner of the home page. This serves to identify the company - yet does not get in the way of the finicky shopper.

Navigation links or buttons should be located at the top of the page. The customer should not have to search for them.

Link titles should be direct and to the point. Anticipate what your customer is looking for. “Store”, for example, makes more sense (especially on an international level) than “tag sale”.

In many cases, being too wordy can turn customers away. Copy should be brief. If you are posting lengthy blocks of text (such as what you are reading now), keep paragraphs to no more than two or three sentences.

Avoid large or busy graphics. Keep each page of your web site clean and well organized. The less the customer has to look at, the faster they can purchase your product or service!

The most successful e-commerce web sites implement these principles. According to Nielsen//NetRatings, Amazon.com tops the list. CDnow.com rates in the top 5. Both serve as good examples of smart psychological design.







-----------------------

Okay, that may sound like histrionics, but the job of designing a website is an exercise in promoting a brand or idea in an appealing manner while also eliciting specific human emotions and behaviors. The designer must know how to accomplish these aims within a host of constraints, including those presented by the medium, the physical space, the client's specifics, the relevant social environment, and the content and purpose of the site. In some cases this job is like pulling a rabbit out of a hat. In others, it is like pulling an elephant out of a thimble. Clearly a job for David Copperfield. See what I mean about the need for an artist-psychologist?

http://www.stylegala.com/articles/design_psychology.htm
linkpost comment

(no subject) [Apr. 24th, 2006|03:20 pm]
interesting site about website security

http://www.cgisecurity.com/about.shtml

myspace security increasing storage access

http://www.eweek.com/article2/0,1759,1948704,00.asp
linkpost comment

Analysis of Myspace.com [Apr. 24th, 2006|02:58 pm]
Analysis of the HTML at myspace.com
This article analyses the HTML code at myspace.com.

Myspace.com is a community website that lets people with similar interests interact with each other.

The thing that seems to have taken to peoples hearts is the ability to create a profile page in their own style utilising HTML and CSS.

There are problems associated with creating profiles with myspace.com in that the HTML involved is very convoluted and therefore adding CSS styles isn't that easy.

This article has been written to specify how the HTML code at myspace.com is put together so that you can amend your profile knowing exactly what it is you are changing.

Create an account at myspace.com
If you haven't got a myspace.com account then Click this link to create a myspace account.

Where do I put the CSS
The CSS is the key to amending your myspace.com profile. To add CSS you use specify

You may have noticed that only the edges of the background turned red. This is because the tables sit on top of the body and they have been given default styles



The colour can be specified as an actual colour, an rgb value or in hex. Read more about colors here.

You can also change the background image. To set a background image add the following code:




Tables, Tables, Tables, Tables
The html of a profile at myspace.com is very rigid and is built up of a number of tables.

The most annoying thing is that none of the tables have been labelled and even where they have been the editor does not allow the use of the # character which prevents individual css access.

There isn't as much control over the editing of a profile as I personally would like.

You may have noticed in the body section above that only the edges of the background turned red. This is because the tables sit on top of the body and they have been given default styles.

To make it so that the whole page is red or so that your background image shines through you have to manipulate the CSS for each set of tables.



Accessing the outer tables in this way isn't overly useful but gives you access to borders for view more pics, contacting, myspace url, interests, details, companies, blurbs and friend space

Its far more useful to actually change the td element of the outer tables as follows:

table table table table td
{
background: cyan;
}




As you can see in the image above the differences are much more dramatic with a number of sections turning cyan. These sections include view more pics, contacting, myspace url, interests, details, companies, blurbs and friend space.

Myspace.com html analysis - TABLE, TABLE, TABLE


table table table
{
background: gold;
padding: 2px;
border: 0px solid black;
}



To access the next level out you need to access table table table as shown in the code above.

By setting a background colour for table table table you are giving the inner tables table table table table a border.

You can also access the colour schemes for extended network, myspace url (outer part only) and blog entries.

table table table td
{
background: red;
border: 0px;
}

By changing the inner cell (td) you can change the inner properties of extended network, myspace url, blog entries and the top part of blurb.



Contact Table



table.contacttable table
{
background: green;
border: 1px solid silver;
}
table.contacttable td {
background: green;
border: 0px solid silver;
}


The contact table unlike any other table has been given the classname of contacttable which means it can be accessed directly as the above code shows.

By adding table.contacttable table and table.contacttable td you can change the properties of the whole contact area within your myspace.com profile.

If you didn't want to amend the header you could just have accesssed table.contacttable table td

Changing header details on a myspace.com profile
The header text for contact details, interests, details and companies is controlled by the classname .whitetext12.

So by adding:





Changing text colours
The heading text is not the only text that can be changed.

The following table shows different classnames and what they change on your profile:

Class Description
.lightbluetext8 Sets the description text colour for interests and details
.blacktext12 Sets the text colour for extended description
.btext Sets the text colour for latest blog entry
.orangetext15 Sets the text colour for blurbs, about me, who I'd like to meet, friend space and friend comments
.redbtext Sets the text colour for number of friends
.redtext Sets the text colour for 0 of 0 in friend's comments

How to change the text color of your myspace url (added 13/3/2006)
Changing the text color of the myspace url is a little bit different to all the other areas of the page.

The text for the myspace url are held within a
section under table table table td.

To amend the color of myspace url add the following code.

table table table td div {color:gold;}
Remember to replace the word gold with the color that you wish to use.

Summary
You can use any CSS styles as shown in the CSS Tutorial. You can also add your own HTML in each section to enable you to add new sections and detail to your page.

Click here to view my myspace.com profile.

The styles for my myspace profile are as follows:

HTML Tutorial
http://www.easywebpagedesign.com/html_tutorial.html

CSS Tutorial
http://www.easywebpagedesign.com/css_tutorial.html
linkpost comment

High Quality websites [Apr. 24th, 2006|01:02 pm]
Dramatic & effective use of Flash, exceptional integration & flow, interesting use of audio . . . bridging the gap on traditional media.
http://www.balthaser.com/builder/fx_boot.asp

Great education resources & quality galleries. A Top Pick for both achievement & content.
http://chandra.harvard.edu/

High quality Flash enabled site - dynamic, effective & very well integrated. There are few words, yet this site says a lot. Quality designers & multimedia developers.
http://www.neostream.com/

top take-away (PDF) resources, excellent site design & quality Flash presentations.
http://www.profitpatterns.com/

Refined & effective Flash work from this design firm providing quality 3D animation, multimedia, marketing & Internet solutions.
http://www.3dreality.net/

Superb educational resources, excellent entertainment & fun zones, friendly virtual navigation - a fantastic contribution to the promotion of quality science & technology.
http://www.questacon.edu.au/index_flash.asp

Great Flash work from this German active media & web design firm. The demos in the showcase reflect many advanced skills.
http://www.eye4u.com/

http://www.hillier.com/home/


Interactive city map of Varazdin Croatia - an innovative & sophisticated synergy between form & function - allowing 360 degree navigation, zooming & photo addresses
http://www.2000.varazdin.com/

http://movies.real.com/?rnd=1145898947109&bw=372&has-player=true&version=6.0.12.1040

Stunning graphics, useful education resources & amazing Continuum containing some exceptional designers & digital artists - real surf.
http://www.stimulus.com/v/5/flash/v5.swf


http://www.worldbest.com/flash.htm

Our judges are drawn from the following backgrounds.

* Artistry & design
* HTML & technical networking effectiveness
* Marketing & business effectiveness
* Psychological & techno-social impact
* Personal (surfers)
linkpost comment

World's best websites: what to emulate, what to discard? [Apr. 24th, 2006|12:53 pm]
STAR 1 - Functionality (20%)

Accessibility

001. breadth of browser compatibility
002. minimum & maximum monitor resolutions
003. plain text/HTML alternate entry paths
004. appeal to universal audience - multilingual translations, cultural sensitivity, disability access & services

Speed & Bandwidth Sensitivity

005. overall page sizes & complexity
006. average download times
007. download order & image redraws
008. wait to first reaction/interaction times



HTML Quality

009. clean HTML with no faulty code
010. workability of active x, rollovers, applets, etc.
011. page titles, descriptions, keywords & tags
012. Java & Javascript dependency, image dependency

Navigation & Links

013. navigation functionality & clarity
014. link integrity
015. quality & depth of links provided
016. external Vs internal link ratios for access to core information

Legality

017. original artwork, music, intellectual property etc.
018. international copyright laws are correctly observed
019. quotations, images & intellectual property from 3rd parties are appropriately cited
020. legal site content & legal site activities

STAR 2 - Design (20%)

Graphic Design

021. exceptional artistry
022. elegance & sophistication of core design concepts
023. typography & font styles
024. clever synergies of visual elements

User Friendliness

025. ease of use
026. aids, tools & help resources
027. interface functionality
028. clarity & simplicity



Aesthetics & Beauty

029. visual appeal
030. professional appearance
031. artistic integration
032. color harmonies

Alignment & Layout

033. general layout & use of space
034. complexity & quality of tables
035. effective use of layers
036. use of borders, dividers, rules

Integration

037. effectiveness of unified feel
038. congruence of elements
039. audio-visual synchronization
040. consolidation & reinforcement of purpose

STAR 3 - Content (20%)

Purpose

041. specific mission or website goals
042. message & its expression
043. usefulness & quality of content, free resources etc.
044. reason to return

Human Interactivity

045. customer/surfer interaction processes
046. membership & community facilities
047. Email lists, newsletters, newsgroups, chat, BB
048. other value added services provided

Information Process

049. simplification of complex components, use of synopsis & summaries
050. information architecture, primary purpose, construct clarity, chunking, packaging, FAQ's & RFC
051. perceptual clarity, focus of attention, visibility of functions
052. information access - content rating systems, usability, search facility, site map, steps to destination, readability, effectiveness of image maps

Verbal Expression

053. clarity of grammar & use of language
054. articulation of complex concepts
055. spelling, punctuation etc.
056. absence of duplication & repetition

Attention to detail

057. absence of mistakes &/or inaccuracy
058. absence of incongruities
059. absence of dead ends & outdated pages
060. absence of process failures & code crash

STAR 4 - Originality (20%)

Innovation & Lateral Thinking

061. uniqueness & rarity of offerings
062. commendable insight or utility
063. advanced, unusual, or clever solutions
064. innovation in content worthy of public merit

Creativity

065. originality of components
066. elegance & sophistication
067. style variation from industry fashions
068. creative use of resources

Technology

069. effective use of leading edge technologies - Java, DHTML, active X, advanced coding, XML, CSS, peer to peer
070. compression technologies, RealPlayer, Flash, Beatnik
071. audio & video broadcast, use of streaming media
072. database integration & functionality

Distinctiveness

073. resonance in memory
074. multi-sensory appeal & impact
075. strength of emotional impression &/or evocative attitude
076. strength of "mindprint"

Vision

077. forward thinking
078. advanced solutions
079. leading-edge activities
080. quality of predictive research

STAR 5 - Professionalism & Effectiveness (20%)

Customer Service & Client Respect

081. ease of contact & responsiveness
082. management of requests & complaints from customers
083. customer testimonials provided
084. refund policy & privacy practices published

Values

085. business ethics, absence of "clever rorts"
086. honesty in advertising & self representations
087. contributions &/or support of worthy public causes
088. free services/tools/facilities provided

Focus

089. clarity & potency of message delivery
090. absence of unrequested intrusions (e.g. pop ups)
091. absence of "attention clash"
092. absence of conceptual "dissonance"

Advanced Components

093. WAP & WebTV formats
094. use of interactive maps & other active media
095. active server & dynamically generated pages
096. e-commerce solutions, secure servers or advanced systems/technologies not listed in other categories.

Overall Site Effectiveness

097. professionalism in achieving website goals
098. website traffic & statistics
099. potency of impact
100. prompts to action

Copyright 1998-2004 World Best Enterprises. All Rights Reserved.



Judging Criteria - Level 2 -

All factors examined in Level One will also apply in Level Two - PLUS:
Significance of websites role & function, citations, awards, site linkages, prominence in Internet community.

Exemplary Innovation - lateral solutions, paradigm busting innovations, leading edge contributions, industry leadership.

Quality Standards - ISO apply in industry?, certifications, industry endorsements, awards, member of appropriate professional associations, qualifications of staff for service provided.

Site Performance Analysis - traffic patterns through the site, scan flow analysis, data analysis systems, effective use of autoresponders (if appropriate).

Search Engine Visibility - effective use of titles, meta tags, & page content, keyword relevancy, accuracy of summary descriptions, clarity of purpose.

Search Engine Rankings - top positions on principle keywords & phrases, page rankings, adherence to search engine protocol, effectiveness of tag coding.

URL clarity - domain distinctiveness, memorability, competitive positioning, address permanence.

Differentiation & Branding Strategy - strength of logo, label & other psychological, perceptual & emotional "anchors" of brand, marketing strategy, viral marketing, ethical utilization of email, chat & community forums.

Business Analysis (where applicable) - customer data collected, Email lists & Newsletters available, clarity of business process & efficiencies, E Commerce facilities, SSL, price lists, shopping carts, invoices, accuracy of billing, timeliness, order fulfillment, back end database integration, customer relations, marketing & advertising effectiveness.

Server Security Checks (written authorizations required) advanced security analysis - port scans, trojan sweeps, vulnerability profiles, firewall setups, network sniffers, software & application faults, e-mail vulnerabilities, database & human interface weaknesses.

Hosting Efficiency - bandwidth type & availability, uptime, internal network, ISP, global mirrors, cluster servers?

Surfer Votes & Customer Endorsements - site popularity & active consumer support

http://www.worldbestwebsites.com/gold.htm
linkpost comment

Learning the technical design aspect [Apr. 24th, 2006|12:35 pm]
Best Copy/Writing

Only copy and writing judged.


Best Home/Welcome Page

Only home or welcome page judged.


Best Navigation/Structure

Only information architecture judged.

Best Practices

Best Practices sites serve as an industry benchmark for the most current, innovative, and advanced practices in Web development. Sites demonstrating unparalleled excellence across The Academy's six criteria: content, structure & navigation, visual design, interactivity, functionality, and overall experience.

Best Use of Animation or Motion Graphics

Only animation and motion graphics judged.

Best Use of Video or Moving Image

Only video or moving image judged.




Best Visual Design - Aesthetic

Only visual design judged. Geared toward sites and experiences where visual design is intended to be beautiful, emotional, and appeal to the senses.




Best Visual Design - Function

Only visual design judged. Geared toward sites that rely on visual design as a critical part of a functional user experience.



The Academy evaluates Web sites based on six criteria: content, structure and navigation, visual design, functionality, interactivity, and overall experience.

Web critique, like Web development, is not an exact science. Powerful new ideas and applications arise constantly, reshaping old ideas or paving over them. Not every Webby Award winner or nominee scores 10's across the judging table. The weight of each category varies with the goal of each site; a Web site is much more than the sum of its parts.

Criteria

Content
Structure and Navigation
Visual Design
Functionality
Interactivity
Overall Experience
Content

Content is the information provided on the site. It is not just text, but music, sound, animation, or video -- anything that communicates a sites body of knowledge. Good content should be engaging, relevant, and appropriate for the audience. You can tell it's been developed for the Web because it's clear and concise and it works in the medium. Good content takes a stand. It has a voice, a point of view. It may be informative, useful, or funny but it always leaves you wanting more.

Structure and Navigation

Structure and navigation refers to the framework of a site, the organization of content, the prioritization of information, and the method in which you move through the site. Sites with good structure and navigation are consistent, intuitive and transparent. They allow you to form a mental model of the information provided, where to find things, and what to expect when you click. Good navigation gets you where you want to go quickly and offers easy access to the breadth and depth of the site's content.

Visual Design

Visual design is the appearance of the site. It's more than just a pretty homepage and it doesn't have to be cutting edge or trendy. Good visual design is high quality, appropriate, and relevant for the audience and the message it is supporting. It communicates a visual experience and may even take your breath away.

Functionality

Functionality is the use of technology on the site. Good functionality means the site works well. It loads quickly, has live links, and any new technology used is functional and relevant for the intended audience. The site should work cross-platform and be browser independent. Highly functional sites anticipate the diversity of user requirements from file size, to file format and download speed. The most functional sites also take into consideration those with special access needs. Good functionality makes the experience center stage and the technology invisible.

Interactivity

Interactivity is the way that a site allows you to do something. Good interactivity is more than a rollover or choosing what to click on next; it allows you, as a user, to give and receive. It insists that you participate, not spectate.

It's input/output, as in searches, chat rooms, e-commerce and gaming or notification agents, peer-to-peer applications and real-time feedback. It's make your own, distribute your own, or speak your mind so others can see, hear or respond. Interactive elements are what separates the Web from other media. Their inclusion should make it clear that you aren't reading a magazine or watching TV anymore.

Overall Experience

Demonstrating that sites are frequently more -- or less than the sum of their parts, the overall experience encompasses content, structure and navigation, visual design, functionality, and interactivity, but it also includes the intangibles that make one stay or leave. One has probably had a good overall experience if (s)he comes back regularly, places a bookmark, signs up for a newsletter, participates, emails the site to a friend, or stays for a while, intrigued
linkpost comment

Programming BREAK...Our website beginnings [Apr. 24th, 2006|11:52 am]
How to design the best website possible:


THE WEBBY AWARDS

The leading international award honoring excellence in Web design, creativity, usability and functionality.

In its 10th year, the Webby Awards is presented by The International Academy of Digital Arts and Sciences, a 500-member body of leading web experts, business figures, luminaries, visionaries and creative celebrities.

http://www.webbyawards.com

Many categories are judged, the most interesting that we can learn from are the following:

Broadband (MAKE AN INTERACTIVE SITE: PEOPLE WILL COME BACK i.e. MYSPACE)

Sites fully integrating bandwidth-intensive interactive content. This content may include video, animation, and like dynamic elements that bring the computer, television, radio and film one step closer to convergence.

Charitable Organizations / Non-Profit (?)

Sites for charities and charitable organizations whose primary purpose is helping people or other worthy causes.

Community (A BLOG FEATURE)

Sites creating and facilitating online community, connectedness and/or communication around shared interests. These sites can target either a broad-based or niche audience

Education (COURSE CATALOGUE AND STUDENT OPINIONS)

Sites that are educational, promote education, or provide online curriculum or education services. This category includes educational content for children or adults, resources for educators, and "distance learning" courses. Does not include school sites, see School.

Employment (STUDENT EMPLOYMENT)

Sites featuring job and employment listings, job and career search services, recruiting services, career advice, headhunting or other career or job related information

Events (LOCAL SHOWS)

Sites promoting specific events including concerts, fairs, festivals, sporting events, tours, or other events.

Family/Parenting

Sites providing content related to family issues, child rearing, family activities, pregnancy, parenting tips and other information.

Food and Beverage (POPULAR LOCAL RESTARAUNTS)

Sites promoting food and beverage products including snack foods, candy, confections, chewing gum, fresh and frozen food, soft drinks, juices, energy drinks and water. Also sites featuring content about food or beverages, including recipes or recommendations.

Financial Services (STUDENT LOANS FOR US)

Sites providing financial services and/or information. These include online stock trading, financial news, mortgage information, credit cards, or investor relations and services. Does not include online banking sites. See Banking/Bill Paying.

Government (STUDENT INTERESTED IN POLITICS)

Sites providing information and services pertaining to government matters. These include sites that enable online citizen action, offer self-help information, publish government documents and forms, and provide access to services provided by government agencies.

Guides/Ratings/Reviews (REVIEWS OF CLASSES)

Sites that provide reviews of products or services for either consumer or business audiences. These include restaurant reviews, travel reviews, business product or service reviews, buying guides, best-of resources, product and price comparison sites.


Health (HOSPITALS, FAMILY PLANNING)

Sites providing information and resources to improve personal health and well-being. These may include medical news sites, health information, and online diagnosis. Health includes not only medicine but also includes alternative and mental health and fitness Web sites.

Humor (JOKES FEATURED)

Sites dedicated to comedy or the art of laughter.

Insurance (STUDENT HEALTH AND CAR INSURANCE)

Sites providing information, commerce or other services featuring insurance products and services for home, auto, liability, business or any other purposes.

Youth

Sites for those under 18: kids, youth, adolescents, teens and young adults.

Weird

Sites that just seem strange, offbeat or odd. This category includes sites that reflect a fresh perspective in thought and action strong enough to start a revolution, change a behavior pattern, or advance old thinking lodged in bad habits, or that are just plain weird.

Tourism (WHAT THE HELL DO WE DO)

Sites that promote travel and tourism destinations, specific travel activities or promotional and informational tourism websites. Includes city, country or regional sites, tourist attractions, and chamber of commerce sites.

Sports (GATOR FOOTBALL, BASKETBALL, BASEBALL)

Sites for sports news, sporting culture, sports teams, sports statistics, sports data, sporting events, and sports history. Includes fantasy sports sites.




Student

For students who have designed web sites for academic purposes or as part of developing a portfolio. Category limited to works of students.


Services

Sites allowing real world activities to be done online. These include agent or bot sites as well as sites that help people find jobs, houses, dates, or which otherwise facilitate typically offline activities from a keyboard.




Social/Networking

Sites that facilitate the process of connecting individuals through the Internet. Their purpose may be business or pleasure. They may use friend-of-friend connections to form a social network or use technology to make the connection. Includes dating and matchmaking sites.


School/University

Sites for schools (high school, secondary school, elementary school), specialty school, technical school, colleges, universities and other schools.

Real Estate (APARTMENTS)

Sites marketing or promoting the sale or rental of residential or commercial real estate, including real estate listings, brokers and brokerage services, real estate agents, and sites for developments, buildings or other real estate holdings.


Professional Services (STUDENT OPINIONS)

Sites for professional service firms including consultants of any type, accountants and other business service providers.


News- SCHOOL NEWSPAPER

Sites developed for the distribution of recent happenings. These may be offshoots of established broadcast or other existing news operations, or developed specifically for online news.

Law

Web sites for law firms, legal service providers, pro-bono legal services, litigation support, and self-help legal information. Sites that feature content on legal issues, trials, law and business issues, court decisions or legal advocacy.




Lifestyle

Sites featuring commentary, commerce and advice on lifestyle and living topics such as gardening, home improvement, interior design, architecture, and like subjects. Sites touching on the personal side of life by providing information and resources that allow people to live on their own terms.




Magazine

Sites that are online editions or companions to offline business or consumer magazines, or sites published only online ('zines).


Newspaper

Sites that are online editions or companions to offline newspapers




Religion and Spirituality

Sites focusing on the spirit or the soul, evangelizing spiritual practice, celebrating God(s) or any other divine power - traditional or otherwise. These include sites which provide information about the ritual, history and practice of all forms of spirituality, church and temple sites, online confessions, virtual prayer groups, and astrology sites as well as sites that provide a platform for direct online spiritual experience


Telecommunications (PHONE SERVICES THAT WORK BEST)

Sites for cellular or mobile phones, accessories, voice over IP, phone service, long distance service, ring tones, or any other mobile or land-line phone or phone service



Travel

Sites that provide travel services and information. These include online agents for purchasing tickets, hotel rooms, rental cars, vacation packages and other travel services. Includes online travel guides, travel writing, and travel tools
linkpost comment

Simple Sequences [Apr. 19th, 2006|11:21 am]
What will we cover?

Single commands
The use of Python as a calculator
Using parentheses to get the correct result
Using format strings to print complex output
How to quit Python from within a program.

A simple sequence of instructions is the most basic program you can write. The simplest sequence is one containing a single command. We will try out some of these now. The heading will describe what you should type at the '>>>' Python prompt, the following paragraph will explain what happens.

>>> print 'Hello there!'
The print command is the way to get Python to display its results to you. In this case it is printing the sequence of characters H,e,l,l,o, ,t,h,e,r,e,!. Such a sequence of characters is known in programming circles as a string of characters or a character string or just a plain string.

You signify a string by surrounding it in quotes. In Python you can use either single quotes(as above) or double quotes: "a string ". This allows you to include one type of quote within a string which is surrounded by the other type - useful for apostrophes:

>>> print "Monty Python's Flying Circus has a ' within it..."

It's not just characters that can be printed:

>>>print 6 + 5

Here we have printed the result of an arithmetic operation - we added six and five. Python recognized the numbers as such and the plus sign and did the sum for us. It then printed the result.

So straight away you have a use for Python: it's a handy 'pocket calculator'! Try a few more sums. Use some other arithmetic operators:

subtract (-)
multiply (*)
divide (/)
We can combine multiple expressions like this:

>>> print ((8 * 4) + (7 - 3)) / (2 + 4)

Notice the way I used parentheses to group the numbers together. What happens if you type the same sequence without the parentheses? This is because Python will evaluate the multiplication and division before the addition and subtraction. This is usually what you would expect mathematically speaking but it may not be what you expect as a programmer! All programming languages have rules to determine the sequence of evaluation of operations and this is known as operator precedence. You will need to look at the reference documentation for each language to see how it works. With Python it's usually what logic and intuition would suggest, but occasionally it won't be...

As a general rule it's safest to include the brackets to make sure you get what you want when dealing with long series of sums like this.

One other thing to note:

>>> print 5/2

results in a whole number (integer) result (i.e. 2). This is because Python sees that the numbers are whole numbers and assumes you want to keep them that way. If you want decimal fractions as a result simply write one number as a decimal:

>>> print 5/2.0
2.5

Python sees the 2.0 and realizes that we are happy dealing with fractions (referred to as real numbers or floating point in computing parlance), so it responds with a fractional result. In the most recent versions of Python you can change this behavior to always produce real numbers from a division by adding this line to the top of your program:
>>> from __future__ import division

(Note, that's two underscores on each side of future)

Its likely that this will be the standard type of division in some future version of Python but for now you have to specifically tell Python that you want it turned on.

If you want to keep with whole numbers you can find the remainder by using the % sign like a division operator. Python will print the remainder:

>>> print 7/2
3
>>> print 7%2
1
>>> print 7%4
3
% is known as the modulo or mod operator and in other languages is often seen as MOD or similar.

Experiment and you will soon get the idea.

>>>print 'The total is: ', 23+45

You've seen that we can print strings and numbers. Now we combine the two in one print statement, separating them with a comma. We can extend this feature by combining it with a useful Python trick for outputting data called a format string:

>>> print "The sum of %d and %d is: %d" % (7,18,7+18)

In this command the format string contains '%' markers within it. The letter 'd' after the % tells Python that a 'decimal number' should be placed there. The values to fill in the markers are obtained from the values inside the bracketed expression following the % sign on its own

There are other letters that can be placed after the % markers. Some of these include:

%s - for string
%x - for hexadecimal number
%0.2f - for a real number with a maximum of 2 decimal places
%04d - pad the number out to 4 digits with 0's

The Python documentation will give lots more...

In fact you can print any Python object with the print command. Sometimes the result will not be what you hoped for (perhaps just a description of what kind of object it is) but you can always print it.

>>>import sys
Now this is a strange one. If you've tried it you'll see that it apparently does nothing. But that's not really true. To understand what happened we need to look at the architecture of Python (for non Python programmers, bear with me there will be a similar mechanism available to you too!)

When you start Python there are a bunch of commands available to you called built-ins, because they are built in to the Python core. However Python can extend the list of commands available by incorporating extension modules. - It's a bit like buying a new tool in your favourite DIY shop and adding it to your toolbox. The tool is the sys part and the import operation puts it into the toolbox.

In fact what this command does is makes available a whole bunch of new 'tools' in the shape of Python commands which are defined in a file called 'sys.py'. This is how Python is extended to do all sorts of clever things that are not built in to the basic system. You can even create your own modules and import and use them, just like the modules provided with Python when you installed it.

So how do we use these new tools?

>>>sys.exit()
Whoops! What happened there? Simply that we executed the exit command defined in the sys module. That command causes Python to exit. (Note: Normally you exit Python by typing the End Of File(EOF) character at the >>> prompt - CTRL-Z on DOS or CTRL-D on Unix)

Notice that exit had 2 brackets after it. That's because exit is a function defined in sys and when we call a Python function we need to supply the parentheses even if there's nothing inside them!

Try typing sys.exit without the brackets. Python responds by telling you that exit is a function rather than by executing it!

One final thing to notice is that the last two commands are actually only useful in combination. That is, to exit from Python other than by typing EOF you need to type:

import sys
sys.exit()

This is a sequence of two commands! Now we're getting closer to real programming....

---------------------------------------------------------------------------------------------------------
Using JavaScript
Unfortunately in JavaScript there is no easy way to type the commands in and see them being executed immediately as we have been doing with Python. However we can type all of the simple commands we used above into a single HTML file and load it into a browser. That way we will see what they look like in JavaScript:





And the output should look like this:


Hello there!Monty Python's Flying Circus has a ' within it1162.51


Notice that we had to write
to force a new line. That's because JavaScript writes its output as HTML and HTML wraps lines into as wide a line as your browser window will allow. To force a line break we have to use the HTML symbol for a new line which is
.
---------------------------------------------------------------------------------------------------------
And VBScript too...
Like JavaScript we have to create a file with our VBScript commands and open it in a browser. The commands that we have seen, written in VBScript look like this:





And the output should consist of lots of dialog boxes each presenting the output from one line of the program.

One point to note is that you cannot start a string using a single quote in VBScript (We'll see why in a later topic) although you can include single quotes inside double quoted strings. To include a double quote inside a double quoted string we have to use a function called Chr which returns the character for a given ASCII character code. I'ts all very messy but an example should show how it works:



Note that you can find out the ASCII code for any character by using the Character Map applet in Windows, or by visiting this web site and looking up the decimal value or, as a last resort, by using the following bit of JavaScript(!) and replacing the double quote character with the character you want:



Don't worry about what it means just yet, we'll get to it eventually for now just use it should you be forced to find out an ASCII value.

That's our first look at programming, it wasn't too painful was it? Before we continue though we need to take a look at the raw materials of programming, namely data and what we can do with it.

Points to remember
Even a single command is a program
Python does math almost the way you'd expect
To get a fractional result you must use a fractional number
You can combine text and numbers using the % format operator
Quit with import sys; sys.exit()
linkpost comment

Python/Javascript/VBscript [Apr. 18th, 2006|07:13 pm]
Using Python

For the next set of exercises I will assume you have a properly installed version of Python on your computer. If not, go fetch the latest version from the Python web site and follow the install instructions for your platform.

Now from a command prompt type python and the Python prompt should appear looking something like this:

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Alternatively you might find a shortcut to something called IDLE, or the Python GUI, in your start menus. If you start IDLE instead of the command line version you will get a similar prompt but in a window of its own and with some pretty font colors! Danny Yoo has written a pretty good IDLE Tutorial to get you started with IDLE and I recommend you pay it a visit if you want to stick with it rather than the basic command prompt. It duplicates some of the early material here but repetition of the basics is no bad thing!

The full manual for IDLE is found here. For now I'd recommend you stick with Danny's tutor.

One interesting thing about IDLE is that it is itself a Python program, so it's a very good demonstration of just what is possible using Python

If you got your version of Python from ActiveState or if you downloaded the Windows specific extensions (the winall package), you also have access to another GUI programming environment, very similar to IDLE but perhaps a little more polished, called Pythonwin. Either Pythonwin or IDLE make far better programming environments than the standard DOS prompt, but at the very beginning I prefer to use the most basic tools to focus on the underlying principles rather than the toys.
---------------------------------------------------------------------------------------------------------
A word about error messages
If you type in the commands as we go through them then sooner or later you will get an error message. It will look something like this:



>>> print 'fred' + 7
Traceback (most recent call last):
File "<input ... >", line 1, in ?
TypeError: cannot concatenate 'str' and 'int' objects

Don't worry about the exact meaning here just look at the structure.
The '>>> print ...' line is the erroneous command
The next 2 lines are describing where the error occurred:
'line 1 in ?' means line 1 in the command we are typing. If it were a longer program stored in a source file the <input ... > would be replaced by the file name.

The 'TypeError...' line tells you what the interpreter thinks is wrong and sometimes there will be a caret character(^) pointing to the part of the line that Python thinks is at fault.
Unfortunately this will often be wrong, usually the error is earlier in the line, or even in the (one or two) lines immediately preceding where Python says it is - remember computers are dumb!

Use the error information to figure out what's happening. Remember it's most likely to be you at fault not the computer. Remember again that computers are dumb. Probably you just mistyped something or forgot a quote sign or something similar. Check carefully.

In case you are wondering, the mistake I made was trying to add a number to a character string. You're not allowed to do that so Python objected and told me there was a TypeError. You'll need to wait till we get to the topic on the Raw Materials to understand what types are all about....

Whichever approach you've decided to take, command prompt or IDLE (or Pythonwin) we are ready to start creating some very simple Python programs.
---------------------------------------------------------------------------------------------------------
JavaScript
To create JavaScript programs in a browser we need to do a bit more work. We need to create an HTML file which we can load into a web browser. An HTML file is really just a plain text file which you can create in Notepad or any other text editor. The file will look like this:











The bit between
[Error: Irreparable invalid markup ('<script...>') in entry. Owner must fix manually. Raw contents below.]

<b>Using Python</b>

For the next set of exercises I will assume you have a properly installed version of Python on your computer. If not, go fetch the latest version from the Python web site and follow the install instructions for your platform.

Now from a command prompt type python and the Python prompt should appear looking something like this:

Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Alternatively you might find a shortcut to something called IDLE, or the Python GUI, in your start menus. If you start IDLE instead of the command line version you will get a similar prompt but in a window of its own and with some pretty font colors! Danny Yoo has written a pretty good IDLE Tutorial to get you started with IDLE and I recommend you pay it a visit if you want to stick with it rather than the basic command prompt. It duplicates some of the early material here but repetition of the basics is no bad thing!

The full manual for IDLE is found here. For now I'd recommend you stick with Danny's tutor.

One interesting thing about IDLE is that it is itself a Python program, so it's a very good demonstration of just what is possible using Python

If you got your version of Python from ActiveState or if you downloaded the Windows specific extensions (the winall package), you also have access to another GUI programming environment, very similar to IDLE but perhaps a little more polished, called Pythonwin. Either Pythonwin or IDLE make far better programming environments than the standard DOS prompt, but at the very beginning I prefer to use the most basic tools to focus on the underlying principles rather than the toys.
---------------------------------------------------------------------------------------------------------
<b>A word about error messages</b>
If you type in the commands as we go through them then sooner or later you will get an error message. It will look something like this:

<img src="http://www.freenetpages.co.uk/hp/alan.gauld/tutstart.htm">

>>> print 'fred' + 7
Traceback (most recent call last):
File "<input>", line 1, in ?
TypeError: cannot concatenate 'str' and 'int' objects

Don't worry about the exact meaning here just look at the structure.
The '>>> print ...' line is the erroneous command
The next 2 lines are describing where the error occurred:
'line 1 in ?' means line 1 in the command we are typing. If it were a longer program stored in a source file the <input> would be replaced by the file name.

The 'TypeError...' line tells you what the interpreter thinks is wrong and sometimes there will be a caret character(^) pointing to the part of the line that Python thinks is at fault.
Unfortunately this will often be wrong, usually the error is earlier in the line, or even in the (one or two) lines immediately preceding where Python says it is - remember computers are dumb!

Use the error information to figure out what's happening. Remember it's most likely to be you at fault not the computer. Remember again that computers are dumb. Probably you just mistyped something or forgot a quote sign or something similar. Check carefully.

In case you are wondering, the mistake I made was trying to add a number to a character string. You're not allowed to do that so Python objected and told me there was a TypeError. You'll need to wait till we get to the topic on the Raw Materials to understand what types are all about....

Whichever approach you've decided to take, command prompt or IDLE (or Pythonwin) we are ready to start creating some very simple Python programs.
---------------------------------------------------------------------------------------------------------
JavaScript
To create JavaScript programs in a browser we need to do a bit more work. We need to create an HTML file which we can load into a web browser. An HTML file is really just a plain text file which you can create in Notepad or any other text editor. The file will look like this:

<img src="http://www.freenetpages.co.uk/hp/alan.gauld/tutstart.htm">

<html>
<body>

<script language="JavaScript">

document.write('Hello World\n');

</script>

</body>
</html>

The bit between <script...> and </script> is our program. I won't be showing all the HTML tags every time in this tutorial so you need to copy that file each time as a template and then replace everything between the script tags with the code you want to try out.
---------------------------------------------------------------------------------------------------------
VBScript
VBScript is essentially the same as JavaScript with the single difference that you replace the name "JavaScript" in the language= bit with, surprisingly enough, "VBScript". Like this:

<img src="http://www.freenetpages.co.uk/hp/alan.gauld/tutstart.htm">

<html>
<body>

<script language="VBScript">

MsgBox "Hello World"

</script>

</body>
</html>

Once again the bit between the <script> tags is the program

---------------------------------------------------------------------------------------------------------

VBScript and JavaScript errors
In both VBScript and JavaScript you will get a dialog box pop up telling you the line number of an error. There will also be a fairly inscrutable error message. As with Python, treat the line number as a rough guide rather than an exact pointer. After finding and fixing the error you will need to reload (or refresh) the page in your web browser.

OK, Whichever language you choose you are ready to start.

Points to remember
Start python by typing python at a command prompt
Error messages are nothing to be scared of, read them carefully, they usually give a clue as to why you got them.
But it's only a clue... if in doubt check the lines immediately before the reported line
linkpost comment

Back Tracking: The beginning of programming [Apr. 17th, 2006|03:47 pm]
Computer Programming is the art of making a computer do what you want it to do.

At the very simplest level it consists of issuing a sequence of commands to a computer to achieve an objective. In the Microsoft world MS DOS users used to create text files with lists of commands called BAT files. These simply executed the sequence of commands as a BATCH, hence the name. You can still produce these in Windows environments today but in practice they are rarely seen.

For example you might be producing a document (such as this tutorial) which comprises lots of separate files. Your word processor may produce backup copies of each file as it saves a new version. At the end of the day you may want to put the current version of the document (all the latest files) into a 'backup' directory/folder. Finally, to tidy up, delete all the backup files ready to start work the next day. A simple BAT file to do this would be:

COPY *.HTM BACKUP
DEL *.BAK

If the file were called SAVE.BAT then at the end of each day I could simply type SAVE at a DOS prompt and the files would be saved and backups deleted. This is a program.

Note: Users of Linux or other operating systems have their own versions of these files often known as shell scripts. Unix shell scripts are much more powerful than DOS BAT files, and support most of the programming techniques that we will be discussing in this course.

Just as you speak to a friend in a language so you 'speak' to the computer in a language. The only language that the computer understands is called binary and there are several different dialects of it - which is why that cool iMac program won't run on your PC and vice versa. Binary is unfortunately very difficult for humans to read or write so we have to use an intermediate language and get it translated into binary for us. This is rather like watching the American and Russian presidents talking at a summit meeting - One speaks in English, then an interpreter repeats what has been said in Russian. The other replies in Russian and the interpreter again repeats the sentence, this time in English.

Surprisingly enough the thing that translates our intermediate language into binary is also called an interpreter. And just as you usually need a different interpreter to translate English into Russian than you do to translate Arabic into Russian so you need a different computer interpreter to translate Python into binary from the one that translates VBScript into binary.

The very first programmers actually had to enter the binary codes themselves, this is known as machine code programming and is incredibly difficult. The next stage was to create a translator that simply converted English equivalents of the binary codes into binary so that instead of having to remember that the code 001273 05 04 meant add 5 to 4 programmers could now write ADD 5 4. This very simple improvement made life much simpler and these systems of codes were really the first programming languages, one for each type of computer. They were known as assembler languages and Assembler programming is still used for a few specialized programming tasks today.

Even this was very primitive and still told the computer what to do at the hardware level - move bytes from this memory location to that memory location, add this byte to that byte etc. It was still very difficult and took a lot of programming effort to achieve even simple tasks.

Gradually computer scientists developed higher level computer languages to make the job easier. This was just as well because at the same time users were inventing ever more complex jobs for computers to solve! This competition between the computer scientists and the users is still going on and new languages keep on appearing. This makes programming interesting but also makes it important that as a programmer you understand the concepts of programming as well as the pragmatics of doing it in one particular language.

I'll discuss some of those common concepts next, but we will keep coming back to them as we go through the course

A long time ago a man called Edsger Dijkstra came up with a concept called structured programming. This said that all programs could be structured in the following four ways:

Sequences of instructions:



Here the program flows from one step to the next in strict sequence


Branches:



Here the program reaches a decision point and if the result of the test is true then the program performs the instructions in Path 1, and if false it performs the actions in Path 2. This is also known as a conditional construct because the program flow is dependent on the result of a test condition

Loops:



In this construct the program steps are repeated continuously until some test condition is reached, at which point control then flows past the loop into the next piece of program logic.

Modules:



Here the program performs an identical sequence of actions several times. For convenience these common actions are placed in a module, which is a kind of mini-program which can be executed from within the main program. Other names for such a module are: sub-routine, procedure or function.


Along with these structures programs also need a few more features to make them useful:

Data (we take a closer look at data in the Raw Materials topic.)
Operations (add, subtract, compare etc.
- we also take a look at the operations we can perform on data in the Raw Materials topic.)
Input/Output capability (e.g. to display results
- we look at how to read data in the "Talking to the User" topic.)
Once you understand those concepts and how a particular programming language implements them then you can write a program in that language

We already said that programming was the art of making a computer do what you want, but what is a program?

In fact there are two distinct concepts of a program. The first is the one perceived by the user - an executable file that is installed and can be run repeatedly to perform a task. For example users speak of running their "word processor program". The other concept is the program as seen by the programmer, this is the text file of instructions to the computer, written in some programming language, that can be translated into an executable file. So when you talk about a program always be clear about which concept you mean.

Basically a programmer writes a program in a high level language which is interpreted into the bytes that the computer understands. In technical speak the programmer generates source code and the interpreter generates object code. Sometimes object code has other names like: P-Code, binary code or machine code.

The interpreter has a couple of names, one being the interpreter and the other being the compiler. These terms actually refer to two different techniques of generating object code from source code. It used to be the case that compilers produced object code that could be run on its own (an executable file - another term) whereas an interpreter had to be present to run its program as it went along. The difference between these terms is now blurring however since some compilers now require interpreters to be present to do a final conversion and some interpreters simply compile their source code into temporary object code and then execute it.

From our perspective it makes no real difference, we write source code and use a tool to allow the computer to read, translate and execute it.

The exact structure of a program depends on the programming language and the environment that you run it on. However there are some general principles:

A loader - every program needs to be loaded into memory by the operating system. The loader does this and is usually created by the interpreter for you.
Data definitions - most programs operate on data and somewhere in the source code we need to define exactly what type of data we will be working with. Different languages do this very differently.
Statements - these are the core of your program. The statements actually manipulate the data we define and do the calculations, print the output etc.
Most programs follow one of two structures:

Batch programs
These are typically started from a command line (or automatically via a scheduler utility) and tend to follow a pattern of:



That is, the program will typically start off by setting its internal state, perhaps setting totals to zero, opening the needed files etc. Once it is ready to start work it will read data either from the user by displaying prompts on a screen or from a data file. Most commonly a combination is used whereby the user provides the name of the data file and the real data is read from the file. Then the program does the actual data processing involving math or data conversion or whatever. Finally the results are produced, either to a screen display or, perhaps, by writing them back to a file.

All the programs we write in the early parts of this tutorial will be batch style programs.

Event driven programs
Most GUI systems (and embedded control systems - like your Microwave, camera etc) are event driven. That is the operating system sends events to the program and the program responds to these as they arrive. Events can include things a user does - like clicking the mouse or pressing a key - or things that the system itself does like updating the clock or refreshing the screen.

Event driven programs generally look like:



In this configuration the program again starts off by setting up its internal state, but then control is handed off to the event loop - which is usually provided by the operating environment (sometimes referred to as the runtime). The program then waits for the event loop to detect user actions which it translates to events. These events are sent to the program to deal with one at a time. Eventually the user will perform an action that terminates the program, at which point an Exit Event will be created and sent to the program.

We look at event loops and event driven programming in the "Advanced Topics" section and again in the GUI programming topic.

Points to remember
Programs control the computer
Programming languages allow us to 'speak' to the computer at a level that is closer to how humans think than how computers 'think'
Programs operate on data
Programs can be either Batch oriented or Event driven


http://www.freenetpages.co.uk/hp/alan.gauld/
linkpost comment

(no subject) [Apr. 17th, 2006|01:17 pm]
EX. 1

strings of text

print "Hello world"

Hello world


EX. 2

the lines beginning with # are called comments and are actually ignored by the computer. However, inserting small explanations like this can be important in making your programs more readable to humans


# The Area of a Rectangle

# Ingredients:

width = 20
height = 30

# Instructions:

area = width*height
print area

the lines that look like foo = bar are called assignments. In the case of width = 20 we tell the computer that the width should be 20 from this point on.

What does it mean that "the width is 20"? It means that a variable by the name "width" is created (or if it already exists, it is reused) and given the value 20. So, when we use the variable later, the computer knows its value.

Thus,

width*height

is essentially the same as

20*30

which is calculated to be 600, which is then assigned to the variable by the name "area". The final statement of the program prints out the value of the variable "area", so what you see when you run this program is simply

600


Note: In some languages you have to tell the computer which variables you need at the beginning of the program (like the ingredients of the salad) – Python is smart enough to figure this out as it goes along

EX 3

In the case of calculating the area of a circle:

We need feedback, or input. How does the computer know the radius of our circle? It too needs input... What we can do is to tell it to check the radius:

radius = input("What is the radius?")

print radius*radius*3.14

Now things are getting snazzy... input is something called a function. (You'll learn to create your own in a while. input is a function that is built into the Python language.) Simply writing

input

won't do much... You have to put a pair of parantheses at the end of it. So input() would work – it would simply wait for the user to enter the radius.

When we put something like the question-string "What is the radius?" between the parentheses of a function call it is called passing a parameter to the function. The thing (or things) in the parentheses is (or are) the parameter(s). In this case we pass a question as a parameter so that input knows what to print out before getting the answer from the user.

But how does the answer get to the radius variable? The function input, when called, returns a value (like many other functions). You don't have to use this value, but in our case, we want to. So, the following two statements have very different meanings:

foo = input

bar = input()

foo now contains the input function itself (so it can actually be used like foo("What is your age?"); this is called a dynamic function call) while bar contains whatever is typed in by the user.

we are still limited to so-called sequential execution of the commands, that is – they have to be executed in a fixed order

EX. 4


In reference to a recipe/cooking analogy,

What we want to do, is to control the flow of the program. It can go in two directions]

The condition is whether or not it is properly heated. This is called conditional execution

temperature = input("What is the temperature of the spam?")

if temperature > 50:
print "The salad is properly cooked."
else:
print "Cook the salad some more."

Note: The indentation is important in Python. Blocks in conditional execution (and loops and function definitions – see below) must be indented (and indented by the same amount of whitespace; a counts as 8 spaces) so that the interpreter can tell where they begin and end. It also makes the program more readable to humans.

EX 5

The program is quite simple: It asks for a number, which tells it whether the user wants to calculate the area of a rectangle or a circle. Then, it uses an if-statement (conditional execution) to decide which block it should use for the area calculation. These two blocks are essentially the same as those used in the previous area examples. Notice how the comments make the code more readable. It has been said that the first commandment of programming is: "Thou shalt comment!" Anyway – it's a nice habit to acquire.



# Area calculation program

print "Welcome to the Area calculation program"
print "---------------------------------------"
print

# Print out the menu:
print "Please select a shape:"
print "1 Rectangle"
print "2 Circle"

# Get the user's choice:
shape = input("> ")

# Calculate the area:
if shape == 1:
height = input("Please enter the height: ")
width = input("Please enter the width: ")
area = height*width
print "The area is", area
else:
radius = input("Please enter the radius: ")
area = 3.14*(radius**2)
print "The area is", area


New things in this example:

print used all by iself prints out an empty line
== checks whether two things are equal, as opposed to =, which assigns the value on the right side to the variable on the left. This is an important distinction!
** is Python's power operator – thus the squared radius is written radius**2.
print can print out more than one thing. Just separate them with commas. (They will be separated by single spaces in the output.)

If you have more than two choices, you can write something like:

if foo == 1:
# Do something...
elif foo == 2:
# Do something else...
elif foo == 3:
# Do something completely different...
else:
# If all else fails...

Here elif is a mysterious code which means "else if" :). So; if foo is one, then do something; otherwise, if foo is two, then do something else, etc. You might want to add other options to the programs too – like triangles or arbitrary polygons. It's up to you.

Sequential execution and conditionals are only two of the three fundamental building blocks of programming. The third is the loop or repeated execution.


Python has two loop types: while-loops and for-loops. For-loops are perhaps the simplest. For instance:

for food in "spam", "eggs", "tomatoes":
print "I love", food

This means: For every element in the list "spam", "eggs", "tomatoes", print that you love it. The block inside the loop is executed once for every element, and each time, the current element is assigned to the variable food (in this case). Another example:

for number in range(1,100):
print "Hello, world!"
print "Just", 100 - number, "more to go..."

print "Hello, world"
print "That was the last one... Phew!"


The function range returns a list of numbers in the range given (including the first, excluding the last... In this case, [1..99]). So, to paraphrase this:

The contents of the loop is executed for each number in the range of numbers from (and including) 1 up to (and excluding) 100. (What the loop body and the following statements actually do is left as an exercise.)

we use while:

# Spam-cooking program

# Fetch the function sleep
from time import sleep

print "Please start cooking the spam. (I'll be back in 3 minutes.)"

# Wait for 3 minutes (that is, 3*60 seconds)...
sleep(180)

print "I'm baaack :)"

# How hot is hot enough?
hot_enough = 50

temperature = input("How hot is the spam? ")
while temperature < hot_enough:
print "Not hot enough... Cook it a bit more..."
sleep(30)
temperature = input("OK. How hot is it now? ")

print "It's hot enough - You're done!"

New things in this example...

Some useful functions are stored in modules and can be imported. In this case we import the function sleep (which sleeps for a given number of seconds) from the module time which comes with Python. (It is possible to make your own modules too...)

http://www.hetland.org/python/instant-hacking.php
linkpost comment

Python For Absolute Beginners: New to Programming Altogether [Apr. 16th, 2006|06:59 pm]
http://www.coolnamehere.com/geekery/python/pythontut.html

Which Version of Python?
There are two versions of Python available for download:

1.ActiveState ActivePython
2.Python 2.4.3

Which one you install is mostly a personal choice. The language itself is the same, regardless of version. The main differences are the type of support you can get, and the tools that they come packaged with.

The ActiveState version has the benefit of being from a real, live company. You can purchase support and take advantage of the fact that it comes from a single source. It (the Windows version, anyways) comes with the excellent PythonWin program for developing your Python programs in a Windows environment. Because of the support and the Windows-friendly tools, ActivePython may be the best choice for business users.

***Python 2.4, on the other hand, is the "official" version. It comes with a standard set of tools which are available on every platform that Python can support. Instead of PythonWin, Python 2.4 comes with IDLE: a cross-platform graphical environment for developing your Python programs. IDLE works pretty much the same for you whether you are sitting in front of a Windows or a Linux machine. It's the version that I'm using for the tutorial, so maybe that has some bearing on your decision.

Installing Python in a Non-Windows Environment

Linux could mean installing RPM's, compiling from source (my favorite), or some other tactic that I forgot. If you would like some kind of pointer for installing Python under Linux, check out this page, which includes a decent overview of installation from RPM's and source.

The Redhat distribution of Linux has started making Python 2.x available in the regular installation process. I know for certain that Redhat version 7.2 has it, and it might be available in earlier versions too. It's the "python2" packages. After you've installed it, you can use this tutorial pretty much as is, except that you call "python2" from the command line instead of "python".

http://www.python.org/doc/Intros.html

That page has links to articles which discuss Python, tutorials, and comparisons to other languages. Python was largely written for educational environments: learning how to do things "the Python way" makes it easier to write clean, readable programs for any language. Plus, its flexibility makes it useful way past the classroom.

Although I will be focussing on IDLE (and the simple stuff, at that), you can just as easily use PythonWin or the Python shell (which you get into from the console by typing python.

IDLE is Python's Integrated DeveLopment Environment

IDLE gives you access to everything you need to write Python code in a graphical pointy-clicky environment like Windows. There's a version of the Python shell, as well as features allowing you to write, save, and run your own Python programs with ease.

You can find documentation for IDLE at:

http://www.python.org/idle/doc/idlemain.html

It's a pretty standard, dry user manual, but should hold answers to any questions you might come up with for the details of using IDLE.

In the next couple of sections, I'll help you with the basics of using IDLE. We'll use the shell for some simple code, and make & run our own little Python script.

How to use IDLE
Starting IDLE under Windows is a matter of finding it in your Start menu.

Find the Python folder in your Start menu.
Find the menu item for IDLE within the Python folder.
Select it.
Given the wide, wild range of desktop environments available for Linux, there is no way I could simply tell you which menu option runs IDLE. Instead, you get these instructions:

Open a terminal (XTerm, Eterm, Gnome Terminal ... whatever)
In the terminal, type idle[ENTER]
If you happen to have IDLE in your environment's equivalent of a Start menu, then you can just use that.

IDLE will start with something that looks like some sort of command line interface (kind of like a colorful DOS box or XTerm). That is the shell, and it allows you to perform the next step:

Using the IDLE Shell (Writing Code!)
Let's see, how do we run Python code in the IDLE shell?

Type it in and watch it go!

The IDLE shell allows you to enter code (from simple statements to function and class definitions), and execute it immediately. Since you have the shell open already, type in this example:

>>> print "Hello, world!"
Hello world

The '>>>' is the shell prompt, showing that you can type something here. You don't type that in yourself).

Press the ENTER key, and the shell will perform that command right away:

>>> print "Hello, world!"
Hello, world!

raw_input() is a function that displays a prompt to the user, gets some keyboard input from them, and sends what they typed back to you.

I want to use that typed-in name in a moment, so I save the result in the variable name. A variable is basically just something you want the computer to remember so that you can use it later.

What's a function? Don't worry about that today. Basically, it's something you feed data into, and get data out of - kind of a mini-program in your program. That's all we need to know for right now.

When you press [ENTER] this time, you will be shown a prompt. In IDLE, this prompt shows up simply as some text printed out in the shell, but in PythonWin it opens a little window showing the message you handed to raw_input() and a space for giving your answer.

When you want to get at a value that Python has stored for you, all you have to do is call it by name

Every time you normally tell Python to print something, it will print that something out, and then start a new line. If you paste a comma onto the end of the thing you want to print, it's just like a comma in conversation. It means that you're pausing for air, and the sentence isn't done yet. Instead of starting a new line, Python just inserts a space. The next thing that gets printed will show up on the same line.

In this case, Python prints the phrase "Hello", followed by a space, and ending with the name that was given to it by raw_input().

You can print several things at once, too. Just put a comma in between each item to be printed.

>>> print "Hello", name, "- good to see you!"
Hello Brian - good to see you

http://www.coolnamehere.com/geekery/python/pythontut.html
linkpost comment

Python Tutorial 1: Whetting Your Appetite [Apr. 16th, 2006|06:48 pm]
Writing a large shell script, need to add another feature
Problems: already too slow and/or complicated
system call or other function only accessible by using C
requires data types- sorted lists of file names, variable length strings not easily written in C

Usual C write/compile/test/re-compile cycle is too slow
Problem: need to write more quickly

Written a program that can use an extension language
Problem: Don't want to design a language, design and write and debug an interpreter for it

Python
-simple to use
-real programming language
-offers much more structure and support for large programs than the shell has
-offers much more error checking than C,
- a very-high-level language, it has high-level data types built in, such as flexible arrays and dictionaries that would cost you days to implement efficiently in C.
-applicable to a much larger problem domain than Awk or even Perl, yet many things are at least as easy in Python as in those languages
-allows you to split your program in modules that can be reused in other Python programs
*modules provide things like file I/O, system calls, sockets, and even interfaces to graphical user
interface toolkits like Tk.

-an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary.
-interpreter can be used interactively, which makes it easy to experiment with features of the language, to write throw-away programs, or to test functions during bottom-up program development.

Programs written in Python are typically much shorter than equivalent C or C++ programs, for several reasons:

the high-level data types allow you to express complex operations in a single statement;
statement grouping is done by indentation instead of beginning and ending brackets;
no variable or argument declarations are necessary.

Python is extensible: if you know how to program in C it is easy to add a new built-in function or module to the interpreter, either to perform critical operations at maximum speed, or to link Python programs to libraries that may only be available in binary form
linkpost comment

(no subject) [Apr. 3rd, 2006|03:14 pm]
Kernighan & Pike's The Unix Programming Environment

March Rochkind's Advanced Unix Programming

W. Richard Stevens's Advanced Programming In The Unix Environment.

Maurice J. Bach's The Design Of The Unix Operating System

The Design and Implementation Of The 4.4BSD Operating System by Kirk McKusick, Keith Bostic et. al

Unix Power Tools, Tim O'Reilly, ed

Portable C And Unix Systems Programming

Don Libes's and Sandy Ressler's Life With Unix

The New Hacker's Dictionary (Eric S. Raymond, ed., with Guy L. Steele Jr.).

In this day of Boot-Time Autoconfiguration and Dynamically Loadable Device Drivers, reassembling a Kernel is no longer the daunting Test and Seal of Mastery that once it was. However, writing and verifying thine own Device Driver for some piece of Exotic Hardware is still a worthy challenge to thy Budding Guruhood

Therefore: seek thee out the Open Source Unixes: OpenBSD, FreeBSD, NetBSD, and most Especially Linux in many of its Incarnations

The Art of Unix Programming

Ideally, you should read this book near the console of a running Unix system, with a Web browser handy. Any Unix will do, but the software case studies are more likely to be preinstalled and immediately available for inspection on a Linux system.

n this book we use “Unix” in the looser sense widely current among programmers, to refer to any operating system (whether formally Unix-branded or not) that is either genetically descended from Bell Labs's ancestral Unix code or written in close imitation of its descendants. In particular, Linux (from which we draw most of our examples) is a Unix under this definition.

For more, type man 1 man at your Unix shell prompt (older System V Unixes may require man -s 1 man).

Sometimes we mention a Unix application (such as Emacs), without a manual-section suffix and capitalized. This is a clue that the name actually represents a well-established family of Unix programs with essentially the same function, and we are discussing generic properties of all of them. Emacs, for example, includes xemacs.

In this context, it's associated with the rise of scripting languages, GUIs, open-source Unixes, and the Web. Old-school refers to the pre-1990 (and especially pre-1985) world of expensive (shared) computers, proprietary Unixes, scripting in shell, and C everywhere.


cdrtools/xcdroast
These two separate projects are usually used together. The cdrtools package is a set of CLI tools for writing CD-ROMs; Web search for “cdrtools”. The xcdroast application is a GUI front end for cdrtools; see the xcdroast project site.

fetchmail
The fetchmail program retrieves mail from remote-mail servers using the POP3 or IMAP post-office protocols. See the fetchmail home page (or search for “fetchmail” on the Web).

GIMP
The GIMP (GNU Image Manipulation Program) is a full-featured paint, draw, and image-manipulation program that can edit a huge variety of graphical formats in sophisticated ways. Sources are available from the GIMP home page (or search for "GIMP" on the Web).

mutt
The mutt mail user agent is the current best-of-breed among text-based Unix electronic mail agents, with notably good support for MIME (Multipurpose Internet Mail Extensions) and the use of privacy aids such as PGP (Pretty Good Privacy) and GPG (GNU Privacy Guard). Source code and executable binaries are available at the Mutt project site.

xmlto
The xmlto command renders DocBook and other XML documents in various output formats, including HTML and text and PostScript. For sources and documentation, see the xmlto project site.

http://catb.org/~esr/writings/taoup/html/context.html

At least one of Unix's central technologies — the C language — has been widely naturalized elsewhere. Indeed it is now hard to imagine doing software engineering without C as a ubiquitous common language of systems programming.

Under Unix, there is a fairly sharp distinction between transient knowledge and lasting knowledge, and one can know ahead of time (with about 90% certainty) which category something is likely to fall in when one learns it
linkpost comment

Background Linux/Unix [Apr. 3rd, 2006|02:51 pm]
Finding good code to read used to be hard, because there were few large programs available in source for fledgeling hackers to read and tinker with. This has changed dramatically; open-source software, programming tools, and operating systems (all built by hackers) are now widely available.

Step #1
The single most important step any newbie can take toward acquiring hacker skills is to get a copy of Linux or one of the BSD-Unixes or OpenSolaris, install it on a personal machine, and run it.

Yes, there are other operating systems in the world besides Unix. But they're distributed in binary — you can't read the code, and you can't modify it. Trying to learn to hack on a Microsoft Windows machine or under any other closed-source system is like trying to learn to dance while wearing a body cast

Under Mac OS X it's possible, but only part of the system is open source — you're likely to hit a lot of walls, and you have to be careful not to develop the bad habit of depending on Apple's proprietary code

Unix is the operating system of the Internet. While you can learn to use the Internet without knowing Unix, you can't be an Internet hacker without understanding Unix. For this reason, the hacker culture today is pretty strongly Unix-centered

So, bring up a Unix — I like Linux myself but there are other ways (and yes, you can run both Linux and Microsoft Windows on the same machine). Learn it. Run it. Tinker with it. Talk to the Internet with it. Read the code. Modify the code. You'll get better programming tools (including C, LISP, Python, and Perl) than any Microsoft operating system can dream of hosting,

For more about learning Unix, see The Loginataka. You might also want to have a look at The Art Of Unix Programming.

To get your hands on a Linux, see the Linux Online! site; you can download from there or (better idea) find a local Linux user group to help you with installation. From a new user's point of view, all Linux distributions are pretty much equivalent.

You can find BSD Unix help and resources at www.bsd.org.

I have written a primer on the basics of Unix and the Internet.

(Note: I don't really recommend installing either Linux or BSD as a solo project if you're a newbie. For Linux, find a local Linux user's group and ask for help.)
linkpost comment

Programming Languages- Java, C/C++, Perl, and LISP [Apr. 3rd, 2006|02:35 pm]
2) Java is also a good language for learning to program in. It is more difficult than Python, but produces faster code than Python. I think it makes an excellent second language.

Unfortunately, Sun's reference implementation is still proprietary. This is not so much an issue with the Java language itself, as high-quality open-source Java interpreters are readily available;

**the real problem is the class libraries that travel with the language. The open-source class libraries lag behind Sun's. So, if you do choose to learn Java, do it with one of the open-source implementations rather than becoming dependent on Sun's proprietary code

LEARN MANY DIFFERENT LANGUAGES
But be aware that you won't reach the skill level of a hacker or even merely a programmer if you only know one or two languages — you need to learn how to think about programming problems in a general way, independent of any one language. To be a real hacker, you need to get to the point where you can learn a new language in days by relating what's in the manual to what you already know. This means you should learn several very different languages.

3)C, the core language of Unix. C++ is very closely related to C; if you know one, learning the other will not be difficult. Neither language is a good one to try learning as your first.

C is very efficient, and very sparing of your machine's resources. Unfortunately, C gets that efficiency by requiring you to do a lot of low-level management of resources (like memory) by hand. All that low-level code is complex and bug-prone, and will soak up huge amounts of your time on debugging.

it's smarter to use a language that uses the machine's time less efficiently, but your time much more efficiently. Thus, Python.


4) PERL Other languages of particular importance to hackers include Perl and LISP. Perl is worth learning for practical reasons; it's very widely used for active web pages and system administration, so that even if you never write Perl you should learn to read it.

Many people use Perl in the way I suggest you should use Python, to avoid C programming on jobs that don't require C's machine efficiency.

5) LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot. (You can get some beginning experience with LISP fairly easily by writing and modifying editing modes for the Emacs text editor, or Script-Fu plugins for the GIMP
linkpost comment

Learning to be a Hacker Step #1 Learn How to Program PYTHON [Mar. 27th, 2006|01:27 pm]
It's best, actually, to learn all five of Python, C/C++, Java, Perl, and LISP. Besides being the most important hacking languages, they represent very different approaches to programming, and each will educate you in valuable ways.


http://www.catb.org/~esr/faqs/hacker-howto.html#skills1

1. Learn Python (a scripting language)-interpretive language with its own built-in memory management and good facilities for calling and cooperating with other programs, relatively easy for beginners.


Perl, of course, is the 800-pound gorilla of modern scripting languages. It has a comprehensive set of UNIX library and system calls, and a huge collection of Perl modules built by a very active Perl community. The language is commonly estimated to be the CGI language behind about 85% of the ``live'' content on the Net. "More than one way to do it'' lent flavor and expressiveness at a small scale, but made it significantly harder to maintain consistent style across a wider code base

Tcl, Lisp, and Scheme (Perl's inferior competitors)(lots of clever design was rendered almost useless by scanty or nonexistent documentation, incomplete access to POSIX/UNIX facilities, and a small but nevertheless deeply fragmented user community)

Distinguishing Python from other program languages

The first odd feature of Python that everyone notices: the fact that whitespace (indentation) is actually significant in the language syntax.

**Reaction of most hackers to this:
Our culture seems to have retained a pretty accurate folk memory of how nasty those old-style fixed-field languages were. Indeed, the term ``free format'', used back then to describe the newer style of token-oriented syntax in Pascal and C, has almost been forgotten; all languages have been designed that way for decades now.

SOLUTION: Just indent code, pretty much as you would have done in a C program anyway, and it worked.

The language has no analog of the C and Perl brace syntax; instead, changes in indentation delimit statement groups.

Going back to C as a default language.
The days when it made sense to do your own memory management in a new program are long over, outside of a few specialty areas like kernel hacking, scientific computing and 3-D graphics--places where you absolutely must get maximum speed and tight control of memory usage.

For most other situations, accepting the debugging overhead of buffer overruns, pointer-aliasing problems, malloc/free memory leaks and all the other associated ills is just crazy on today's machines.

Python is a compact language, so is C, NOT Perl (many ways to do one thing)

Perl still has its uses. For tiny projects (100 lines or fewer) that involve a lot of text pattern matching, I am still more likely

For anything larger or more complex, I have come to prefer the subtle virtues of Pytho.
linkpost comment

(no subject) [Mar. 23rd, 2006|05:07 pm]
Dreamweaver Guide: a guide for beginners on how to use dreamweaver
http://www.rice.edu/fondren/erc/howto/dw4guide.html



Marshall University Frontpage 2003 Guide.
http://www.marshall.edu/www/webdevel/guide/fp03guide.pdf

Info. can be taken from this page and applied to any webpage you want to design.



Builder.com by cNet. cNet was one of the first mainstream sources for information on pretty much technological. From webpage design to software development. You may want to check out that site as well.

http://builder.com.com/
linkpost comment

(no subject) [Mar. 22nd, 2006|03:44 pm]
http://www.ibdhost.com/help/godaddy/
linkpost comment

C Programming Language [Mar. 21st, 2006|11:31 pm]
What is C?
C is a mid-level structured programming language.

It is low-level enough to allow the programmer to take complete control over program execution, meaning you can do pretty much whatever you want.

It is also high-level enough to make some tasks easier, such as loops, conditionals and function calls.

C does not stand for any abbreviation. The name comes as an evolution of the B language which is based on BCPL language.

There are C compilers for practically every platform, from Intel to Alpha and Sparc, from DOS to Windows, BSD, Linux, Macintosh, UNIX, VMS, Solaris, BeOS. It is not the most portable language, but it can very powerful in the hands of the right programmer.

What Can C Be Used For?
The two biggest are operating systems and scientific applications.

Most operating systems have at least some C in them, although some mix in assembly language and C++. Linux, for example, is mostly C except for the low-level parts that use assembly.

Scientific applications are mainly developed using C under UNIX or Linux environments. Games are often written in C, although more and more they are being written in C++.

Rather than reinventing the wheel, it makes sense to use both C and C++ libraries and ideas next to each other.

What Is The Syntax Like?
C programs start with headers.

They usually contain data definitions: for example, program constants, macros, prototypes, global variables, etc. but not actual logic.



The main block in a C program is the main() function which is a system function including the logic flow of the C program.

Inside the main(), all the local variables are first declared. Next comes the function calls and all the logic of the program.

C programs usually have several pieces that fit together to make a program. Usually you will have a group of source code files that are compiled separately, then linked together into a single executable file. Each source code file will have a header file that describes its contents

Your source code files contain all your code that actually does stuff, the program logic. Multiple files are used for all but the shortest of programs because it just isn't practical to have a single source code file with thousands or even millions of lines of code. It's too difficult to maintain.

Usually, similar functions are grouped together in a single file. For example, one file may contain your program's code for loading and saving its data to disk. Another file may contain the code for displaying the main window. The header files usually contain little or no program logic.

Functions are the cornerstone of C programming. Functions are cohesive blocks of code that perform common tasks. Code reuse is an important programming concept, and functions allow you, the programmer, to achieve this. Rather than typing out the same task a thousand times, you can put it in a function and use that function over and over again. Therefore, program size becomes smaller.

Another Facts is that C uses pointers extensively. It uses them freely than any other Programming Language. Pointers are variables which store the address of other variables. Using pointers U can literaly point to any addressing location of your system

An Example C Program
This is an example of a C program.

/* Include the Standard C functions for input and output */
#include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]

What is C?
C is a mid-level structured programming language.

It is low-level enough to allow the programmer to take complete control over program execution, meaning you can do pretty much whatever you want.

It is also high-level enough to make some tasks easier, such as loops, conditionals and function calls.

C does not stand for any abbreviation. The name comes as an evolution of the B language which is based on BCPL language.

There are C compilers for practically every platform, from Intel to Alpha and Sparc, from DOS to Windows, BSD, Linux, Macintosh, UNIX, VMS, Solaris, BeOS. It is not the most portable language, but it can very powerful in the hands of the right programmer.

What Can C Be Used For?
The two biggest are operating systems and scientific applications.

Most operating systems have at least some C in them, although some mix in assembly language and C++. Linux, for example, is mostly C except for the low-level parts that use assembly.

Scientific applications are mainly developed using C under UNIX or Linux environments. Games are often written in C, although more and more they are being written in C++.

Rather than reinventing the wheel, it makes sense to use both C and C++ libraries and ideas next to each other.

What Is The Syntax Like?
C programs start with headers.

They usually contain data definitions: for example, program constants, macros, prototypes, global variables, etc. but not actual logic.



The main block in a C program is the main() function which is a system function including the logic flow of the C program.

Inside the main(), all the local variables are first declared. Next comes the function calls and all the logic of the program.

C programs usually have several pieces that fit together to make a program. Usually you will have a group of source code files that are compiled separately, then linked together into a single executable file. Each source code file will have a header file that describes its contents

Your source code files contain all your code that actually does stuff, the program logic. Multiple files are used for all but the shortest of programs because it just isn't practical to have a single source code file with thousands or even millions of lines of code. It's too difficult to maintain.

Usually, similar functions are grouped together in a single file. For example, one file may contain your program's code for loading and saving its data to disk. Another file may contain the code for displaying the main window. The header files usually contain little or no program logic.

Functions are the cornerstone of C programming. Functions are cohesive blocks of code that perform common tasks. Code reuse is an important programming concept, and functions allow you, the programmer, to achieve this. Rather than typing out the same task a thousand times, you can put it in a function and use that function over and over again. Therefore, program size becomes smaller.

Another Facts is that C uses pointers extensively. It uses them freely than any other Programming Language. Pointers are variables which store the address of other variables. Using pointers U can literaly point to any addressing location of your system

An Example C Program
This is an example of a C program.

/* Include the Standard C functions for input and output */
#include <stdio.h>

/* This is the main function, where the program starts running */
int main (void)
{
/* Display a short message to the user */
printf ("I charge thee. Speak! \n");

/* Program is done now, return to the operating system */
return 0;
}

What Do I Need To Get Started?
You will need a C compiler. This is available for free with any UNIX-based operating system including Linux. You can download Borland C++ Builder (if you are using Windows) or GNU C++ Compiler (gcc) (if you are using Linux). These compilers can be used for both C and C++.


http://www.programmersheaven.com/zone3/mh174.htm
linkpost comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]

Advertisement