CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Advertisements

Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Computing Components 01/26/11. Announcements & Reminders Programs 1 due Friday, 9/2/11 What is my late policy? Proxy Codes for Labs  You should be able.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
CS102 Introduction to Computer Programming
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs.
Adapted from John Zelle’s Book Slides1 CS177 Python Programming Chapter 1 Computers and Programs.
Chapter 3 Computer Hard ware
CS190/295 Programming in Python for Life Sciences: Lecture 2 Instructor: Xiaohui Xie University of California, Irvine.
Topics Introduction Hardware and Software How Computers Store Data
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Python Programming: An Introduction to Computer Science
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs.
CISC105 General Computer Science Class 1 – 6/5/2006.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Problem Solving Techniques Using Pascal Allen C.-H. Wu Department of Computer Science Tsing Hua University Hsinchu, Taiwan 30043, ROC
Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations.
1 Introduction to C Programming 計算機程式設計 2/22/2012 朱浩華.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Python Programming, 3/e1 Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs.
Python Programming Module 1 Computers and Programs Python Programming, 2/e1.
And now for something completely different…
Chapter 1: Introduction to Computers and Programming
The Study of Computer Science Chapter 0
Java Programming: From the Ground Up
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Programming
The Study of Computer Science Chapter 0
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Computer Science I CSC 135.
Topics Introduction Hardware and Software How Computers Store Data
CS190/295 Programming in Python for Life Sciences: Lecture 2
Class 2.
15-110: Principles of Computing
ICS103 Programming in C 1: Overview of Computers And Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine

Today’s Goals Course information A basic introduction to computers and programs

Course Information Lecture: TT 3:30-4:50pm in ELH 110 Office hours: TT after class Course Prerequisites: none TA: Jake Biesinger – –Office: BH 4082 Grading based on –Homework (5-8 assignments); no exams

Course Goals Introduction to computer programming using python Primary targets of audience: –Students in bio or med areas who are interested in learning a programming language –Or students in other areas who are interested in using computers to solve life science problems

References Recommended textbook:  Python Programming: An Introduction to Computer Science, 2nd, John Zelle Lecture notes, references and assignments will be available from the course website (website link available from EEE)

Teaching format of the course We will alternate between regular lectures and lab sessions. Regular lectures (basic programming techniques, concepts) Lab sessions, led by Jake Biesinger. Attendance is required. This is the way you will practice and improve your programming skills!

Topics to be covered Basic programming concepts: –Intro to computers and programs –Write simple programs –Computing with numbers –Sequences: strings, lists and files –Functions –Loop structures –Classes and object-oriented design Applications in life sciences –Examples from biological and medical areas

Chapter 1: Computers and Programs

 CPU (central processing unit) - the “brain” of the machine, where all the basic operations are carried out, such as adding two numbers or do logical operations  Main Memory – stores programs & data. CPU can ONLY directly access info stored in the main memory, called RAM (Random Access Memory). Main memory is fast, but volatile.  Secondary Memory – provides more permanent storage o Hard disk (magnetic) o Optical discs o Flash drives  Input Devices – keyboard, mouse, etc  Output Device – monitor, printer, etc Hardware Basics

How does CPU execute a program?  The instructions that comprise the program are copied from the secondary memory to the main memory  CPU start executing the program, following a process called the fetch execute cycle 1.Retrieve the first instruction from memory 2.Decode its presentation 3.Perform the appropriate action Fetch, decode, and execute the next instruction

Programming Languages  A program is simply a sequence of instructions telling a computer what to do.  Programming languages are special notations for expressing computations in an exact, and unambiguous way  Every structure in a program language has a precise form (its syntax) and a precise meaning (its semantics)  Python is one example of a programming language. Others include C++, Fortran, Java, Perl, Matlab, …

High-level vs. machine language  Python, C++, Fortran, Java, and Perl are high- level computer languages, designed to be used and understood by humans.  However, CPU can only understand very low-level language known as machine language

High-level vs. machine language Suppose we want the computer to add two numbers.  The instructions that the CPU actually carries out might be something like this: 1.Load the number from memory location 2001 into the CPU 2.Load the number from memory location 2002 into the CPU 3.Add the two numbers in the CPU 4.Store the result into location 2003 With instructions and numbers represented in binary notations (as sequences of 0s and 1s)  In a high-level language (eg. Python): c = a + b

Translate a high-level language to a machine language Programs written in a high-level language need to be translated into the machine language the computer can execute Two ways to do this: a high-level language can be either compiled or interpreted

Compiling a high-level language A compiler is a complex computer program that takes another program written in a high-level language and translates it into an equivalent program in the machine language of some computer

Interpreting a high-level language An interpreter is a program that simulates a computer that understands a high-level language. Rather than translating the source program into a machine language equivalent, the interpreter analyzes and executes the source code instruction by instruction as necessary. To run a program, both the interpreter and the source are required each time. Interpreted languages tend to have more flexible programming environment as programs can be developed and run interactively, but are generally slower than compiled languages.

Python is an interpreted language >>> is a Python prompt indicating that the interpreter is waiting for us to give a command. A complete command is called a statement Start the Python interpreter in an interactive mode

Defining a new function in the interactive mode  Python allows you put a sequence of statements together to create a brand-new command called a function. o The first line tells Python that we are defining a new function called hello. o The following lines are indented to show that they are part of the hello function. o The blank line lets Python know that the definition is finished  Notice that the definition did not cause anything to happen. A function is invoked by typing its name.

Defining a new function with parameters  Commands can have changeable parts called parameters that are placed within the parentheses Now we can called the newly defined function with parameters:

Write Python programs Type definitions into a separate file, called module or script. Save the file on a disk Several ways to run the program: –python chaos.py –>>> import chaos # in the interactive mode As Python imports the module file, each line executes. It’s just as if we had typed them one-by-one at the interactive Python prompt. Once imported, main() can be re-invoked by typing >>> import chaos.main()

Inside a Python program comments: o any text from # through the end of a line o intended for humans, ignored by the Python defining a function called main x is variable, used to give a name to a value so that we can refer to later The statement starting with for is an example of a loop o A loop is a device that tells Python to do the same thing over and over again o The lines indented underneath the loop heading form the body of the loop x = 3.9 * x * (1-x) is an assignment statement: the value on the right-hand side is computed, and is then stored back (assigned) into the variable on the left-and side of =.