1 Programming for Engineers in Python Autumn 2011-12 Lecture 2: More Basics.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
Introducing Programming a general discussion. What is a Program? Sets of instructions that get the computer to do something Programs may be a few lines.
Snick  snack A Working Computer Slides based on work by Bob Woodham and others.
1 Gentle Introduction to Programming Assaf Zaritsky Summer 2010.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
1 Gentle Introduction to Programming Assaf Zaritsky Summer 2009.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
1 Agenda Variables (Review) Example Input / Output Arithmetic Operations Casting Char as a Number (if time allow)
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Using Java's Math & Scanner class. Java's Mathematical functions (methods) (1)
Recitation 1 Programming for Engineers in Python.
1 Computing for Engineers in Python Autumn
Chapter 9 Interactive Multimedia Authoring with Flash - Introduction to Programming “Computers and Creativity” Richard D. Webster, COSC 109 Instructor.
An Introduction to Textual Programming
A revision guide for programming with python. 1.A program is a set of instructions that tells a computer what to do. 2.The role of a programmer is to.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Topics Introduction Hardware and Software How Computers Store Data
CIS Computer Programming Logic
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Programming for Engineers in Python Sawa 2015 Lecture 1: Introduction to Python 1.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Which Language is Better?
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Introduction to Computer Systems and the Java Programming Language.
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.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Lecture 2b Dr. Robert D. Kent.  Structured program development  Program control.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Getting Started With Python Brendan Routledge
Software Engineering Algorithms, Compilers, & Lifecycle.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Foundations of Programming: Java
G. Pullaiah College of Engineering and Technology
Chapter 10 Programming Fundamentals with JavaScript
Agenda Introduction Computer Programs Python Variables Assignment
Topics Introduction Hardware and Software How Computers Store Data
Key Ideas from day 1 slides
Computing Fundamentals
Variables, Expressions, and IO
Software Programming J. Holvikivi 2014.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Chapter 10 Programming Fundamentals with JavaScript
Programming for Engineers in Python
Topics Introduction Hardware and Software How Computers Store Data
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Building Java Programs
Computer Science Core Concepts
Introduction to Programming with Python
Class 2.
Dasar-Dasar Pemrograman 2: Java Basics
COMPUTING.
Presentation transcript:

1 Programming for Engineers in Python Autumn Lecture 2: More Basics

2 Lecture 1: Highlights Functions Control structures (if/else) Strings

3 Today Leftovers from last week Compiler, interpreter Variables, types, operators, scope

4 Installing and Running Python 2.7 Python 2.7 is already installed in the computers’ classroom Install: Windows 32 bit: A “Python 2.7” folder will be created in your Start Menu: IDLE (Python GUI)‎ - recommended working environment ‏ Python (command line)‎ - textual Python interpreter (a little faster, less convenient) Working with IDLE video:

5 String Type

6 Strings Structure

7 Slicing olleH

8 Lists

9 Iterating Over Lists for var in list: print(var) value in list while loop in tirgul

10 Lists Built In Methods

11 Range, Sum

12 Abstruse Goose, Computer Programming 101,Computer Programming 101

13 Abstruse Goose, Under The HoodUnder The Hood

14 Machine Code (Language) Computers understand only machine language Basically looks like a sequence of 1’s and 0’s Very inconvenient to work with and non intuitive All other computer languages were created for human convenience The computer does not understand C/C#/Java/Scala Must be “translated” into machine language

15 Programming Languages Basics A computer program is a sequence of instructions (texts) that can be “understood" by a computer and executed by it A programming language is a machine-readable artificial language designed to express computations that can be performed by a computer

16 Compiler

17 Hello World (in C) ;-)

18 Interpreter

19 Interpreter Python is an interpreted programming language The Read/Evaluate/Print Loop Read an expression Compute its value Print the result Repeat the above

20 Language Selection and Python Goal Runtime vs. Development time Operating systems Platforms Python is appropriate for quick development of small-medium tasks: Experiments Data analysis Small projects Short development-execution rounds

21 Memory

22 Memory (Cont.) The computer memory is composed of a long list of bits Bits are grouped into bytes and words Every byte is numbered sequentially This number is called an address

23 Variables and Types משתנה (variable): יחידת מידע המאכסנת ערך במהלך ריצת התכנית ניתן ל"גשת" למשתנה: לשנות (לא תמיד) או לקבל את ערכו ניתן לבצע פעולות חשבוניות (ואחרות) בעזרת משתנים לכל משתנה מוגדר טיפוס (type) שקובע את אופן ביצוע הפעולות על המשתנה

24 Define Variables variable name value assignment operator Variable x “is of type” Int and is assigned the value 4

25 Why do We Need Variables? Computer programs manipulate data Data is given as input or calculated throughout the program To be later accessed, variables must be remembered Thus, variables are stored in the memory Variable name  memory address

26 Types Determine number of bytes in memory (“locker size”) Determine the operations that are defined for a given variable

27 Some Basic Types

28 Variables and Types

29 Why Do We Need Different Types? Saving memory Execution speed Defined operations Makes compiler “life” easier (not relevant in Python)

30 Arithmetic Operators

31 Example 1

32 Types and Casting

33 Example 3

34 Comparisons

35 Example 1

36 Example 2

37 Logical Operators and or not Truth Tables (1 – True, 0 - False)

38 Scope

Next Week – A Big Jump! A cape will not help – work hard!