1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 6: Introduction to Scripting Languages with Python COMP 144 Programming Language.

Slides:



Advertisements
Similar presentations
Introduction to Python Week 15. Try It Out! Download Python from Any version will do for this class – By and large they are all mutually.
Advertisements

1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 2: Compilation and Interpretation COMP 144 Programming Language Concepts Spring.
1 Introduction to Data Types (Section 7.1) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael.
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 3: Lexical Analysis COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
What is a scripting language? What is Python?
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
1 ) Definition 2) Note on structured and modular programming, and information hiding 3) Example imperative languages 4) Features of imperative languages.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 31: Building a Runnable Program COMP 144 Programming Language Concepts Spring 2002.
Reasons to study concepts of PL
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Introduction to Python John Alexis Guerra Gómez CMSC433 Spring 2010 University of Maryland.
COMP205 Comparative Programming Languages Part 1: Introduction to programming languages Lecture 3: Managing and reducing complexity, program processing.
Data Structures Introduction. What is data? (Latin) Plural of datum = something given.
Introduction to Python. Outline Python IS ……. History Installation Data Structures Flow of Control Functions Modules References.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Python Jordan Miller and Lauren Winkleman CS 311 Fall 2011.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 8: Python’s Files, Modules, Classes and Exceptions COMP 144 Programming Language.
Intro to Python Paul Martin. History Designed by Guido van Rossum Goal: “Combine remarkable power with very clear syntax” Very popular in science labs.
Introduction to a Programming Environment
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 22: Object-Oriented Programming COMP 144 Programming Language Concepts Spring 2002.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 7: Python’s Built-in Types and Basic Statements COMP 144 Programming Language Concepts.
1 Outline 7.1 Introduction 7.2 Implementing a Time Abstract Data Type with a Class 7.3 Special Attributes 7.4Controlling Access to Attributes 7.4.1Get.
3-1 3 Compilers and interpreters  Compilers and other translators  Interpreters  Tombstone diagrams  Real vs virtual machines  Interpretive compilers.
Python Introduction.
CSC 110 A 1 CSC 110 Introduction to Python [Reading: chapter 1]
Language Evaluation Criteria
Introduction to Python Guido van Rossum Director of PythonLabs at Zope Corporation
1 Binding Time and Storage Allocation (Section ) CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
1 Introduction to Scripting Languages with Python Programming Languages Concepts.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 Introduction to Scripting Languages and Perl Basics CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Getting Started with Python: Constructs and Pitfalls Sean Deitz Advanced Programming Seminar September 13, 2013.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Programming Domains 1.Scientific Applications Typically, scientific applications have simple data structures but require large numbers of floating-point.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
Siena Computational Crystallography School 2005
1 Introduction to Scripting Languages (with Perl).
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
Overview: Lecture 6: Dolores Zage. What is a program? n Operations that are to be applied to certain data in a certain sequence (definition holds for.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Programming Languages Meeting 12 November 18/19, 2014.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
Python Joseph Eckstrom, Benjamin Moore, Willis Kornegay.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Fundamentals of Programming I Overview of Programming
Introduction to Perl: Practical extraction and report language
PROGRAMMING LANGUAGES
Compiler Construction (CS-636)
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Lecture 16: Introduction to Data Types
Unit# 8: Introduction to Computer Programming
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to Python
Introduction to Data Structure
CS1110 Today: collections.
Chapter 1: Programming Basics, Python History and Program Components
Lecture 7: Python’s Built-in Types and Basic Statements
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Programming for Business Computing Introduction
Presentation transcript:

1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 6: Introduction to Scripting Languages with Python COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos Jan 23 The University of North Carolina at Chapel Hill

2 COMP 144 Programming Language Concepts Felix Hernandez-Campos Origin of Scripting Languages Scripting languages originated as job control languagesScripting languages originated as job control languages –1960s: IBM System 360 had the Job Control Language –Scripts used to control other programs »Launch compilation, execution »Check return codes Scripting languages got increasingly more powerful in the UNIX worldScripting languages got increasingly more powerful in the UNIX world –Shell programming, AWK, Tcl/Tk, Perl –Scripts used to combine components »Gluing applications [Ousterhout, 97]

3 COMP 144 Programming Language Concepts Felix Hernandez-Campos System Programming Languages System programming languages replaced assembly languagesSystem programming languages replaced assembly languages –Benefits: »The compiler hides unnecessary details, so these languages have a higher level of abstraction, increasing productivity »They are strongly typed, i.e. meaning of information is specified before its use, enabling substantial error checking at compile time »They make programs more portable –SPLs and ALs are both intended to write application from scratch –SPLs try to minimize the loss in performance with respect to ALs –E.g. PL/1, Pascal, C, C++, Java

4 COMP 144 Programming Language Concepts Felix Hernandez-Campos Higher-level Programming Scripting languages provide an even higher-level of abstractionScripting languages provide an even higher-level of abstraction –The main goal is programming productivity »Performance is a secondary consideration –Modern SL provide primitive operations with greater functionality Scripting languages are usually interpretedScripting languages are usually interpreted –Interpretation increases speed of development »Immediate feedback –Compilation to an intermediate format is common

5 COMP 144 Programming Language Concepts Felix Hernandez-Campos Higher-level Programming They are weakly typedThey are weakly typed –I.e. Meaning of information is inferred  Less error checking at compile-time »Run-time error checking is less efficient, but possible Weak typing increases speed of development Weak typing increases speed of development »More flexible interfacing »Fewer lines of code They are not usually appropriate forThey are not usually appropriate for –Efficient/low-level programming –Large programs

6 COMP 144 Programming Language Concepts Felix Hernandez-Campos Typing and Productivity [Ousterhout, 97]

7 COMP 144 Programming Language Concepts Felix Hernandez-Campos Python Guido van Rossum created Python in the early 90sGuido van Rossum created Python in the early 90s –Named after Monty Python’s Flying Circus Python is easy to learnPython is easy to learn –Simple, clean syntax –Elegant object-orientation –Good documentation –Friendly community Python is powerfulPython is powerful –Efficient high-level data structures are part of the language –It has a very comprehensive set of standard libraries –It is easy to implement new functions in C or C++

8 COMP 144 Programming Language Concepts Felix Hernandez-Campos Feeding a 26-foot python The python absolutely refused to eat anything, and while it is possible for a snake to refrain from food for a considerable period, there is an end even to the endurance of a snake. The authorities decided that extreme measures must be taken. The snake was firmly grasped by twelve men, and food, consisting of two rabbits and four guinea pigs, was pushed into its mouth by the aid of a pole. He was then put back into the cage to allow the processes of digestion to resume. (SciAm, 1902)

9 COMP 144 Programming Language Concepts Felix Hernandez-Campos IDLE Integrated Development EnvironmentIntegrated Development Environment We will follow a short tutorial: One Day of IDLE ToyingWe will follow a short tutorial: One Day of IDLE Toying – x.html x.htmlhttp://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/inde x.html –Download IDLE+Python 2.2:

10 COMP 144 Programming Language Concepts Felix Hernandez-Campos Built-in Data Structures: Numbers Integers, floating-point numbers, complex numbers, arbitrarily long integersIntegers, floating-point numbers, complex numbers, arbitrarily long integers –345 –3.45 –3+45j – L OperatorsOperators –+, –, *, /, **, %,… –abs(), floor(),…

11 COMP 144 Programming Language Concepts Felix Hernandez-Campos Built-in Data Structures: Strings Quotes sequences of charactersQuotes sequences of characters –‘Comp 144\nProgramming Language Concepts’ –“Python’s tricks” Raw modeRaw mode –r‘Comp 144\nProgramming Language Concepts’ OperatorsOperators –Concatenation + »“Programming ” + “Language” + “Concepts” –Repetition * »“COMP144 ” * 5

12 COMP 144 Programming Language Concepts Felix Hernandez-Campos Built-in Data Structures: Strings Positional operatorsPositional operators –Index string[i] –Slice string[i:j] –Length len(string) Formatting (extended printf notation)Formatting (extended printf notation) –“This is %s %.1f” % (“python”, 2.2) –name = “python” ver = 2.2 “This is %(name)s %(ver).3f” % vars()

13 COMP 144 Programming Language Concepts Felix Hernandez-Campos Built-in Data Structures: Lists Ordered collection of objectsOrdered collection of objects –They can contain any type of object –They are mutable –E.g. []Empty list [1, ”2”, 3.0]Three-element list [1, [”2”, 4], 3.0]Nested list OperatorsOperators –Access list[index] –Deletion del list[index] –Length len(list)

14 COMP 144 Programming Language Concepts Felix Hernandez-Campos Built-in Data Structures: Lists OperatorsOperators –Concatenation + »[1, 2] + [3, 4] + [5] –Repetition * »[1, 2] * 5 Positional operatorsPositional operators –Index list[i] –Slice list[i:j] –Length len(list) GenerationGeneration –Ranges range(start,end,step)

15 COMP 144 Programming Language Concepts Felix Hernandez-Campos Reading Assignment John K. Ousterhout, Scripting: Higher-Level Programming for the 21 st Century, 1997John K. Ousterhout, Scripting: Higher-Level Programming for the 21 st Century, 1997 – Guido van Rossum and Fred L. Drake, Jr. (ed.), Python tutorial, PythonLabs, 2001.Guido van Rossum and Fred L. Drake, Jr. (ed.), Python tutorial, PythonLabs, –Read chapters 1 to 2 – –Try some examples in IDLE

16 COMP 144 Programming Language Concepts Felix Hernandez-Campos Additional References Mark Lutz and David Ascher, Learning Python, O’Really, 1999.Mark Lutz and David Ascher, Learning Python, O’Really, Guido van Rossum and Fred L. Drake, Jr. (ed.), Python Reference Manual, PythonLabs, 2001.Guido van Rossum and Fred L. Drake, Jr. (ed.), Python Reference Manual, PythonLabs, –