# Computational Mathematics with Python

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Computational Mathematics with Python Basics Claus Führer, Jan Erik Solem, Olivier Verdier Spring 2010 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

2 1 Introduction and Motivation Python vs Other Languages Examples and Demo 2 Concepts Basic Types Variables Lists For Loop 3 Practical Information 1 Boolean Arrays Modifying Arrays Comparing Arrays 2 Iteration 3 Objects and References Copying 4 Objects and Types Type Checking Claus Führer, Methods Jan Erik Solem, and OlivierProperties Verdier Computational Mathematics with Python Spring / 55

3 1 Introduction and Motivation Python vs Other Languages Examples and Demo 2 Concepts Basic Types Variables Lists For Loop 3 Practical Information 1 Boolean Arrays Modifying Arrays Comparing Arrays 2 Iteration 3 Objects and References Copying 4 Objects and Types Type Checking Claus Führer, Methods Jan Erik Solem, and OlivierProperties Verdier Computational Mathematics with Python Spring / 55

4 Why Python? Python is... Free and open source It is a scripting language, meaning that it is interpreted It is modern: object oriented, exception handling, dynamic typing etc. Plenty of libraries, in particular scientific ones: linear algebra; visualisation tools: plotting, image analysis; differential equations solving; symbolic computations; statistics ; etc. Many possible usages: Scientific computing (of course :-)), scripting, web sites, text parsing, etc. Used by YouTube, Google, NASA, Los Alamos, NSA among others Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

5 Python vs language XX Java, C++ Object oriented compiled languages. Very limited and extremely verbose. Low level compared to python. Few scientific libraries. C, FORTRAN Very low level compiled language. Useful in some CPU critical situations. php, ruby Other interpreted languages. PHP is web oriented. Ruby is as flexible as python but has no scientific library. MATLAB Tool for matrix computation that evolved for scientific computing. The scientific library is huge but it is not a programming language. Extremely expensive. Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

6 Examples Python may be used in interactive mode: >>> x = 3 >>> y = 5 >>> print x + y 8 Here we solve [ ] 1 2 x = 3 4 >>> M = array ([[1., 2.], [3., 4.]]) >>> V = array ([2., 1.]) >>> x = solve (M, V) >>> print x [ ] [ ] 2 1 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

7 More examples Computing e iπ and : >>> print exp ( 1j* pi) # should return -1 : -) ( e - 16j ) >>> print 2** L Computing ζ(x) = k=1 1 k x. For x = 2 we know that ζ(2) = π2 6 : # for x = 2: >>> print scipy. special. zeta (2., 1) >>> print pi**2/ Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

8 Demo Demo Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

9 1 Introduction and Motivation Python vs Other Languages Examples and Demo 2 Concepts Basic Types Variables Lists For Loop 3 Practical Information 1 Boolean Arrays Modifying Arrays Comparing Arrays 2 Iteration 3 Objects and References Copying 4 Objects and Types Type Checking Claus Führer, Methods Jan Erik Solem, and OlivierProperties Verdier Computational Mathematics with Python Spring / 55

10 Numbers A number may be an integer, a real number or a complex number. The usual operations are + and - addition and substraction * and / multiplication and division ** power 2**(2+2) # 16 1j**2 # -1 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

11 Strings Strings are lists of characters, enclosed by simple or double quotes: valid string " string with double quotes " Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

12 Strings Strings are lists of characters, enclosed by simple or double quotes: valid string " string with double quotes " You may also use triple quotes for strings including multiple lines: """ This is a long, long string """ Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

13 Concept: Variable Variables A variable is a reference to an object. An object may have several references. One uses the assignment operator = to assign a value to a variable. Example x = [3, 4] # a list object is created y = x # this object now has two labels : x and y del x # we delete one of the labels del y # both labels are removed : the object is deleted Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

14 Concept: Lists Lists A python list is an ordered list of objects, enclosed in square brackets. One accesses elements of a list using zero-based indices inside square brackets. Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

15 List Examples Example L1 = [1, 2] L1[0] # 1 L1[1] # 2 L1[ 2] # raises IndexError L2 = [ a, 1, [3, 4]] L2[0] # a L2[2][0] # 3 L2[-1] # last element : [3,4] L2[- 2] # second to last : 1 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

16 List Utilities range(n) creates a list with n elements, starting with zero: print range ( 5) [0, 1, 2, 3, 4] Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

17 List Utilities range(n) creates a list with n elements, starting with zero: print range ( 5) [0, 1, 2, 3, 4] len(l) gives the length of a list: len ([ a, 1, 2, 34]) # returns 4 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

18 List Utilities range(n) creates a list with n elements, starting with zero: print range ( 5) [0, 1, 2, 3, 4] len(l) gives the length of a list: len ([ a, 1, 2, 34]) # returns 4 Use append to append an element to a list: L = [ a, b, c ] L[-1] # c L. append ( d ) L # L is now [ a, b, c, d ] L[-1] # d Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

19 Comprehensive lists A convenient way to build up lists is to use the comprehensive lists construct, possibly with a conditional inside. Definition The syntax of a comprehensive list is [< expr > for <x> in < list >] Example L = [2, 3, 10, 1, 5] L2 = [x*2 for x in L] # [4, 6, 20, 2, 10] L3 = [ x* 2 for x in L if 4 < x <= 10] # [ 20, 10] laus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

20 Comprehensive Lists in Maths Mathematical Notation This is very close to the mathematical notation for sets. Compare: L 2 = {2x; x L} and L2 = [ 2* x for x in L] One big difference though is that lists are ordered while sets aren t. Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

21 Operations on Lists Adding two lists concatenates (sammanfoga) them: L1 = [1, 2] L2 = [3, 4] L = L1 + L2 # [1, 2, 3, 4] Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

22 Operations on Lists Adding two lists concatenates (sammanfoga) them: L1 = [1, 2] L2 = [3, 4] L = L1 + L2 # [1, 2, 3, 4] Logically, multiplying a list with an integer concatenates the list with itself several times: n*l is equivalent to L + L + + L. } {{ } n times L = [1, 2] 3 * L # [1, 2, 1, 2, 1, 2] Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

23 Concept: for loop for loop A for loop allows to loop through a list using an index variable. This variable is successively equal to all the elements in the list. Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

24 Concept: for loop for loop A for loop allows to loop through a list using an index variable. This variable is successively equal to all the elements in the list. Example L = [1, 2, 10] for s in L: print s * 2, # output : Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

25 Indentation The part to be repeated in the for loop has to be properly indented: for elt in my_list : do_ something () something_ else () etc print " loop finished " # outside the for block Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

26 Repeating a Task One typical use of the for loop is to repeat a certain task a fixed number of time: n = 30 for i in range (n): do_ something # this gets executed n times Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

27 1 Introduction and Motivation Python vs Other Languages Examples and Demo 2 Concepts Basic Types Variables Lists For Loop 3 Practical Information 1 Boolean Arrays Modifying Arrays Comparing Arrays 2 Iteration 3 Objects and References Copying 4 Objects and Types Type Checking Claus Führer, Methods Jan Erik Solem, and OlivierProperties Verdier Computational Mathematics with Python Spring / 55

28 Python Shell Start a python session by typing scipython in a unix shell Check that it is working with: plot(rand(4));show() A window should appear with a graph; you should be able to type other commands without having to close the graph window when you want to quit, write exit() When you want to run python at home please follow the installation instruction on Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

29 Executing Scripts You often want to execute the contents of a file. We recommand to use Kate on the Linux machines (but any other good editor will do) Save your files in (for example) in \$HOME/course/ Type (once) in ipython: cd course To execute the contents of a file named file.py just write execfile( file.py ) in ipython. Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

30 Getting Help Some tips on how to use ipython: To get help on an object just type? after it and then return Use the arrow keys to reuse the last executed commands We will see later that you may use the tabulation key for completion in general Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring / 55

### Computational Mathematics with Python

Boolean Arrays Classes Computational Mathematics with Python Basics Olivier Verdier and Claus Führer 2009-03-24 Olivier Verdier and Claus Führer Computational Mathematics with Python 2009-03-24 1 / 40

### Computational Mathematics with Python

Numerical Analysis, Lund University, 2011 1 Computational Mathematics with Python Chapter 1: Basics Numerical Analysis, Lund University Claus Führer, Jan Erik Solem, Olivier Verdier, Tony Stillfjord Spring

### Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn 2009. Claus Führer Simulation Tools Automn 2009 1 / 65

Simulation Tools Python for MATLAB Users I Claus Führer Automn 2009 Claus Führer Simulation Tools Automn 2009 1 / 65 1 Preface 2 Python vs Other Languages 3 Examples and Demo 4 Python Basics Basic Operations

### Introduction to Python

Introduction to Python Sophia Bethany Coban Problem Solving By Computer March 26, 2014 Introduction to Python Python is a general-purpose, high-level programming language. It offers readable codes, and

### We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

### 1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2015 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive

### AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

AMATH 352 Lecture 3 MATLAB Tutorial MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical analysis. It provides an environment for computation and the visualization. Learning

### Iterative Statements. 1. How is iteration controlled? 2. Where is the control mechanism in the loop? Logical expression or counter.

Iterative Statements The repeated execution of a statement or compound statement is accomplished either by iteration or recursion General design issues for iteration control statements: 1. How is iteration

### Exercise 1: Python Language Basics

Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

### Scripting with TCL, Part 1

Scripting with TCL, Part 1 Axel Kohlmeyer Center for Molecular Modeling University of Pennsylvania SBS 2007 @ JNCASR, Bangalore The VMD Execution Model GUI (FLTK) Internal State Visualization Python Interpreter

### b) lower case always use lower case for all matlab commands. This is what matlab recognizes.

1 Matlab 1) Fundamentals a) Getting Help for more detailed help on any topic, typing help, then a space, and then the matlab command brings up a detailed page on the command or topic. For really difficult

### PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Part 1 Chapter 3 Programming with MATLAB PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction

### WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math

Textbook Correlation WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math Following Directions Unit FIRST QUARTER AND SECOND QUARTER Logic Unit

### Introduction to Mathematics for Software Engineering

Introduction to Mathematics for Software Engineering SET07106 Mathematics for Software Engineering School of Computing Edinburgh Napier University Module Leader: Uta Priss 2010 Copyright Edinburgh Napier

### Intermediate Python Tutorial

Intermediate Python Tutorial Python is free software and is an easy to learn powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented

### PYTHON Basics http://hetland.org/writing/instant-hacking.html

CWCS Workshop May 2009 PYTHON Basics http://hetland.org/writing/instant-hacking.html Python is an easy to learn, modern, interpreted, object-oriented programming language. It was designed to be as simple

### Python Basics. S.R. Doty. August 27, 2008. 1 Preliminaries 4 1.1 What is Python?... 4 1.2 Installation and documentation... 4

Python Basics S.R. Doty August 27, 2008 Contents 1 Preliminaries 4 1.1 What is Python?..................................... 4 1.2 Installation and documentation............................. 4 2 Getting

### CME 193: Introduction to Scientific Python Lecture 1: Introduction

CME 193: Introduction to Scientific Python Lecture 1: Introduction Sven Schmit stanford.edu/~schmit/cme193 1: Introduction 1-1 Contents Administrivia Introduction Basics Variables Control statements Exercises

### Mathematica Programming

program.nb Mathematica Programming Dennis Silverman Mathematical Physics B U. C. Irvine Built in Programming Mathematica already has several important built over and above standard programming languages.

### The Basics of C Programming. Marshall Brain

The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

### Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2

Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................

### Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Exercise 0 Deadline: None Computer Setup Windows Download Python(x,y) via http://code.google.com/p/pythonxy/wiki/downloads and install it. Make sure that before installation the installer does not complain

### Chemical and Biological Engineering Calculations using Python 3. Jeffrey J. Heys

Chemical and Biological Engineering Calculations using Python 3 Jeffrey J. Heys Copyright c 2014 Jeffrey Heys All rights reserved. This version is being made available at no cost. Please acknowledge access

### Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13

Invitation to Ezhil: A Tamil Programming Language for Early Computer-Science Education Abstract: Muthiah Annamalai, Ph.D. Boston, USA. Ezhil is a Tamil programming language with support for imperative

### CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16 Basics of C Remark: Skim Chapters 1 through 6 of Deitel & Deitel. You will notice the following: C is (more or less) a subset of Java. (So, you are

### Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.

Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your

### Method To Solve Linear, Polynomial, or Absolute Value Inequalities:

Solving Inequalities An inequality is the result of replacing the = sign in an equation with ,, or. For example, 3x 2 < 7 is a linear inequality. We call it linear because if the < were replaced with

### Introduction to Matlab

Information Technology Rice University Document UNIX 17 July 11, 2002 Introduction to Matlab Basic Matlab Commands and Syntax This document teaches the user how to create Matlab matrices, learn about Matlab

### Programming Languages & Tools

4 Programming Languages & Tools Almost any programming language one is familiar with can be used for computational work (despite the fact that some people believe strongly that their own favorite programming

### CITS2401 Computer Analysis & Visualisation

FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Lectures 4 and 5 Introduction to Matlab Material from MATLAB

### 3.GETTING STARTED WITH ORACLE8i

Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer

### Microsoft Access 3: Understanding and Creating Queries

Microsoft Access 3: Understanding and Creating Queries In Access Level 2, we learned how to perform basic data retrievals by using Search & Replace functions and Sort & Filter functions. For more complex

### Chapter 3: Control Structures

Chapter 3: Control Structures 1. Higher order organization of Python instructions In the previous chapters, we have introduced the different types of variables known by Python, as well as the operators

### Introduction to MATLAB

Introduction to MATLAB 1 Lecture Series by CEPSTRUM Presented by Pratik Kotkar & Akash Baid Topics.. What is MATLAB?? Basic Matrix Operations Script Files and M-files Some more Operations and Functions

### Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running

### AN INTRODUCTION TO UNIX

AN INTRODUCTION TO UNIX Paul Johnson School of Mathematics September 24, 2010 OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From

### Computer Programming I & II*

Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware

### Certified PHP Developer VS-1054

Certified PHP Developer VS-1054 Certification Code VS-1054 Certified PHP Developer Vskills certification for PHP Developers assesses the candidate for developing PHP based applications. The certification

### Using Casio Graphics Calculators

Using Casio Graphics Calculators (Some of this document is based on papers prepared by Donald Stover in January 2004.) This document summarizes calculation and programming operations with many contemporary

### Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

### Introduction to Perl

Introduction to Perl March 8, 2011 by Benjamin J. Lynch http://msi.umn.edu/~blynch/tutorial/perl.pdf Outline What Perl Is When Perl Should Be used Basic Syntax Examples and Hands-on Practice More built-in

### High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming

### G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P.

SQL databases An introduction AMP: Apache, mysql, PHP This installations installs the Apache webserver, the PHP scripting language, and the mysql database on your computer: Apache: runs in the background

### Introduction to Matlab

Introduction to Matlab Social Science Research Lab American University, Washington, D.C. Web. www.american.edu/provost/ctrl/pclabs.cfm Tel. x3862 Email. SSRL@American.edu Course Objective This course provides

### Introduction. Chapter 1

Chapter 1 Introduction MATLAB (Matrix laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB is especially designed for matrix computations:

### The Julia Language Seminar Talk. Francisco Vidal Meca

The Julia Language Seminar Talk Francisco Vidal Meca Languages for Scientific Computing Aachen, January 16, 2014 Why Julia? Many languages, each one a trade-off Multipurpose language: scientific computing

### 1998. (R. Bird and P. Wadler, Introduction to Functional Programming, Prentice

Mathematical Structures in Programs 15 Algebra) The Shorter Oxford English Dictionary): the reunion of broken parts a calculus of symbols combined according to defined laws Haskell 3 4 Richard Bird. Introduction

### Welcome to Introduction to programming in Python

Welcome to Introduction to programming in Python Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 14, Jan 21, Jan 28, Feb 11 Welcome Fire exits Toilets Refreshments 1 Learning objectives of the course An

### Going from Python to C

Going from Python to C Darin Brezeale December 8, 2011 Python is a high-level, interpreted language. C has many of the same types of programming constructs as in Python: arrays, loops, conditionals, functions,

### Automating tasks through scripting. HPC Certificate Program

Automating tasks through scripting HPC Certificate Program Summary of preparation lectures From "The Shell" at Software Carpentry: Lecture 4: Pipes and Filters The redirect operator saves command output

### Introduction to the TI-83/TI-83+ and TI-84+ for College Algebra.

Introduction to the TI-83/TI-83+ and TI-84+ for College Algebra. Turning it on and off: To turn the calculator on, press the ON key in the lower left corner. You should now see a flashing rectangle, the

### C Programming Language CIS 218

C Programming Language CIS 218 Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language constructs that map efficiently to machine instructions,

### Fall 2016 Bio331: Computational Systems Biology 1 PYTHON2.7 CONCEPTS

Fall 2016 Bio331: Computational Systems Biology 1 PYTHON2.7 CONCEPTS Fall 2016 Bio331: Computational Systems Biology 2 About These Slides These slides serves as a one stop shop for Python concepts we covered

### Modeling with Python

H Modeling with Python In this appendix a brief description of the Python programming language will be given plus a brief introduction to the Antimony reaction network format and libroadrunner. Python

### Linear Equations and Inequalities

Linear Equations and Inequalities Section 1.1 Prof. Wodarz Math 109 - Fall 2008 Contents 1 Linear Equations 2 1.1 Standard Form of a Linear Equation................ 2 1.2 Solving Linear Equations......................

### Internet Traffic Measurements. Shell Scripts. School of Electrical Engineering AALTO UNIVERSITY

Internet Traffic Measurements Shell Scripts School of Electrical Engineering AALTO UNIVERSITY Page 1 Contents What is a shell script?... 2 Useful Linux commands... 2 Useful commands for data manipulation...

### Introduction to Python

WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

### Simple Python Wrestling. Overview. What is Python? 1/28/2014

Simple Python Wrestling Overview How to talk Python Storing Data Making Decisions Looping the loops Collecting data in, er, collections Methods and madness 2 What is Python? Python has been around for

### PHP. Intro, Syntax, Variables, Echo, Data Types

PHP Intro, Syntax, Variables, Echo, Data Types Introduction PHP scripts are executed on the server. What You Should Already Know Before you continue you should have a basic understanding of the following:

### Chapter 1: Introducing Java

Chapter 1: Introducing Java 1. What is Java? Java is a programming language offering many features that make it attractive for mathematical illustration. First, it is a high-level language providing a

### Lab1:IntroductiontoMATLAB

EE 3102: Lab 1 1 Lab1:IntroductiontoMATLAB 1. Warm-up MATLAB is a high-level programming language that has been used extensively to solve complex engineering problems. The language itself bears some similarities

### Java Crash Course Part I

Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

### Getting Started with Matlab (in Computer Science at UBC)

Getting Started with Matlab (in Computer Science at UBC) Ian Mitchell Department of Computer Science The University of British Columbia Why Matlab? Outline Why not C / C++ / Java / Fortran? Why not Perl

### Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

### CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler

CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler 1) Operating systems a) Windows b) Unix and Linux c) Macintosh 2) Data manipulation tools a) Text Editors b) Spreadsheets

### 14:440:127 Introduction to Computers for Engineers. Notes for Lecture 01

14:440:127 Introduction to Computers for Engineers Notes for Lecture 01 Rutgers University, Spring 2010 Instructor- Blase E. Ur 1 What Is Matlab? Matlab ( MATrix LABoratory ) is a software package and

### Using MATLAB for Systems Calculations 1. Basics Eric W. Hansen rev. CRS 6/03

Using MATLAB for Systems Calculations. Basics Eric W. Hansen rev. CRS 6/0 Introduction MATLAB (MATrix LABoratory) is a software package designed for efficient, reliable numerical computing. Using MATLAB

### Software II: Principles of Programming Languages

Software II: Principles of Programming Languages Lecture 8 Statement-Level Control Structures Control Statements: Evolution FORTRAN I control statements were based directly on IBM 704 hardware Much research

### Python as a First Programming Language

STEMBOPS Justin Stevens and Giselle Serate Page 1 Python as a First Programming Language Author: Justin Stevens Giselle Serate 1 Introduction STEMBOPS Davidson Academy of Nevada University of Nevada, Reno

### Counting with While Loops

Simple Loops Iteration Often, we will want a piece of code to run multiple times. This is called iteration or looping. A specific piece of code that is run multiple times is called a loop. While Loop The

### Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University Next 4 lessons: Outline Scientific programming: best practices Classical learning (Hoepfield network) Probabilistic learning

### Introduction to Python

Introduction to Python COMP 089H Fall 2015 Written by Tanya Amert last updated 9/30/15 IDLE IDLE is a simple interactive Python development environment. It consists of a Python shell, which evaluates what

### Systems Programming & Scripting

Systems Programming & Scripting Lecture 14 - Shell Scripting: Control Structures, Functions Syst Prog & Scripting - Heriot Watt University 1 Control Structures Shell scripting supports creating more complex

### Intro to Python. P. TenHoopen - WMLUG. Intro to Python. Slide 1. January 2009

P. TenHoopen - WMLUG Slide 1 What is Python? Python is a cross-platform object-oriented programming language invented by Guido van Rossum. It is an interpreted language but there is support for compiling

### Definition 8.1 Two inequalities are equivalent if they have the same solution set. Add or Subtract the same value on both sides of the inequality.

8 Inequalities Concepts: Equivalent Inequalities Linear and Nonlinear Inequalities Absolute Value Inequalities (Sections 4.6 and 1.1) 8.1 Equivalent Inequalities Definition 8.1 Two inequalities are equivalent

### Introduction to Programming. Oliver Hawkins

Introduction to Programming Oliver Hawkins Introduction to Programming BACKGROUND TO PROGRAMMING LANGUAGES Some languages used for data analysis Python R Julia JavaScript Stata Why Python? Data analysis

### Government Girls Polytechnic, Bilaspur

Government Girls Polytechnic, Bilaspur Name of the Lab: Internet & Web Technology Lab Title of the Practical : Dynamic Web Page Design Lab Class: CSE 6 th Semester Teachers Assessment:20 End Semester Examination:50

### 1. The algebra of exponents 1.1. Natural Number Powers. It is easy to say what is meant by a n a (raised to) to the (power) n if n N.

CHAPTER 3: EXPONENTS AND POWER FUNCTIONS 1. The algebra of exponents 1.1. Natural Number Powers. It is easy to say what is meant by a n a (raised to) to the (power) n if n N. For example: In general, if

### Python lab 2: Modules, arrays, and plotting

Python lab 2: Modules, arrays, and plotting Dr Ben Dudson Department of Physics, University of York 4 th February 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming

### User-defined Functions (UDFs)

User-defined Functions (UDFs) In this lecture I will be introducing the programmation language Visual Basic for Applications (VBA) and explaining one particular use of it: creating UDFs. VBA is a powerful

### INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

### FEEG6002 - Applied Programming 5 - Tutorial Session

FEEG6002 - Applied Programming 5 - Tutorial Session Sam Sinayoko 2015-10-30 1 / 38 Outline Objectives Two common bugs General comments on style String formatting Questions? Summary 2 / 38 Objectives Revise

### grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input

### MATLAB Programming. Problem 1: Sequential

Division of Engineering Fundamentals, Copyright 1999 by J.C. Malzahn Kampe 1 / 21 MATLAB Programming When we use the phrase computer solution, it should be understood that a computer will only follow directions;

### Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

### Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End

### Classroom Tips and Techniques: The Student Precalculus Package - Commands and Tutors. Content of the Precalculus Subpackage

Classroom Tips and Techniques: The Student Precalculus Package - Commands and Tutors Robert J. Lopez Emeritus Professor of Mathematics and Maple Fellow Maplesoft This article provides a systematic exposition

### A Comparison of C, MATLAB, and Python as Teaching Languages in Engineering

A Comparison of C, MATLAB, and Python as Teaching Languages in Engineering Hans Fangohr University of Southampton, Southampton SO17 1BJ, UK fangohr@soton.ac.uk Abstract. We describe and compare the programming

### Access Tutorial 12: An Introduction to Visual Basic

Access Tutorial 12: An Introduction to Visual Basic 12.1 Introduction: Learning the basics of programming Programming can be an enormously complex and difficult activity. Or it can be quite straightforward.

### Scientific Programming, Analysis, and Visualization with Python. Mteor 227 Fall 2015

Scientific Programming, Analysis, and Visualization with Python Mteor 227 Fall 2015 Python The Big Picture Interpreted General purpose, high-level Dynamically type Multi-paradigm Object-oriented Functional

### Introduction to C Programming S Y STEMS

Introduction to C Programming CS 40: INTRODUCTION TO U NIX A ND L I NUX O P E R AT ING S Y STEMS Objectives Introduce C programming, including what it is and what it contains, which includes: Command line

### Models of Motion: Iterative Calculations Fancart

Models of Motion: Iterative Calculations Fancart OBJECTIVES In this activity you will learn how to: Create 3D box objects Update the momentum and position of an object iteratively (repeatedly) to animate

### Stratford School Academy Schemes of Work

Number of weeks (between 6&8) Content of the unit Assumed prior learning (tested at the beginning of the unit) Page 1 of 9 7 The unit is subdivided into six learning hours spread across six lessons in

### Introduction to Shell Programming

Introduction to Shell Programming Timothy Brown February 12, 2015 Specifically bash Research Computing @ CU Boulder Introduction to Shell Programming 1 February 12, 2015 Overview Introduction Variables

### Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

### Euler s Method and Functions

Chapter 3 Euler s Method and Functions The simplest method for approximately solving a differential equation is Euler s method. One starts with a particular initial value problem of the form dx dt = f(t,

### Introduction to Python Programming. CSE 110: Introduction to Computer Science

Introduction to Python Programming CSE 110: Introduction to Computer Science Announcements Labs begin on Wednesday Labs will meet in CS 2129, NOT the CS SINC site! Homework 1 is due in class on Friday

### Outline TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA. What is DrJava? Dr Java

1 Outline TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared