Cs1001 python
Download
1 / 18

CS1001 . Python. - PowerPoint PPT Presentation


  • 252 Views
  • Uploaded on

CS1001 . Python. November 14 th , 2011. Scripting languages. Scripting languages foster an exploratory , incremental approach to writing code Historically interpreted Favor your time and energy over the CPU’s Include libraries for common tasks Examples

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CS1001 . Python.' - curry


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Cs1001 python

CS1001. Python.

November 14th, 2011


Scripting languages
Scripting languages

  • Scripting languages foster an exploratory, incrementalapproach to writing code

  • Historically interpreted

  • Favor your time and energy over the CPU’s

  • Include libraries for common tasks

  • Examples

    • AWK [1977], Perl [1987], Python [1991]


Style
Style

Java: public class HelloWorld { public static void main(String[] args) {System.out.println("Hello world");}}Python:print “hello world”

Perl:print “hello world\n”;

AWK: BEGIN { print "Hello, world!" }


Philosophy
Philosophy

  • More time

    • Thinking about the problem

    • Experimenting with solutions

  • Less time

    • Writing code


Perl

  • Larry Wall, 1987 (linguist)

  • Report writing (text processing!)

  • “There is more than one way to do it.”

  • What was text processing essential for in the early 90s?


Websites per year log scale
Websites per year (log scale)

Source: http://www.useit.com/alertbox/web-growth.html


Which is more important
Which is more important?

  • Code should be easy to write

  • Code should be easy to read

    (This is a false dichotomy)


Obfuscated code contest
Obfuscated code contest

`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=($!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++; $_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`

Perl


Obfuscated code contest1
Obfuscated code contest

`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=($!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++; $_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`

  • $ Just another Perl hacker.

Perl




Python
Python

  • Emphasizes readability

  • “There should be one – and preferably only one – way to do it.”

  • Large standard library (batteries included)

  • Cross platform and open source



Getting the weather
Getting the weather

http://weather.yahooapis.com/forecastrss?w=2459115


Technically
Technically

  • Dynamic typing

  • Garbage collected

  • Multi-paradigm

  • Compiles to bytecode

  • Exception based error handling

  • Extensible


Dynamic typing
Dynamic typing

pi = 3.1459

print pi

pi= "I'dlovetohave " + str(pi) + " pies"

printpi

print"Infact, I'dlikeonemore"

pi = pi + 1 # TypeError: cannotconcatenate 'str' and 'int' objects

printpi


Books
Books

Ordered by technical complexity - notice anything?


Internet humor
Internet humor

Source: http://xkcd.com/534/


ad