Introduction to Python

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

Intro to Python Welcome to the Wonderful world of GIS programing!
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
Introduction to C Programming
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to C Programming
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
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.
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Introduction to Programming Workshop 1 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Python – May 11 Briefing Course overview Introduction to the language Lab.
8/29/2014BCHB Edwards Introduction to Python BCHB Lecture 2.
C Language: Introduction
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
Unit 1 Basic Python programs, functions Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
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.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
Python Let’s get started!.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
9/2/2015BCHB Edwards Introduction to Python BCHB524 Lecture 1.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
9/11/2015BCHB Edwards Introduction to Python BCHB Lecture 3.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Introduction to Programming
Fundamentals of Programming I Overview of Programming
Introduction to Python
CST 1101 Problem Solving Using Computers
Introduction to Python
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Python
Python Let’s get started!.
Introduction to Python
Introduction to Python
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Introduction to Python
Introduction to Python
Variables, Expressions, and IO
Chapter 2 First Java Programs
Introduction to Programming
Introduction to Programming
Perl for Bioinformatics
Introduction to Python
Number and String Operations
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Introduction to Programming Using Python PART 1
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Section 1 Introduction To Programming
Introduction to Programming
Introduction In today’s lesson we will look at: why Python?
Introduction to Python
Introduction to Python
Let’s start from the beginning
Chapter 1: Programming Basics, Python History and Program Components
Input and Output Python3 Beginner #3.
General Computer Science for Engineers CISC 106 Lecture 03
Computer Programming-1 CSC 111
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Hardware is… Software is…
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Python BCHB524 Lecture 1 BCHB524 - Edwards

Outline Why Python? Installation Hello World Simple Numbers BCHB524 - Edwards

Why Python? Free Portable Object-oriented Clean syntax Dynamic Scientific, Commercial Support libraries Extensible Interactive Modern BCHB524 - Edwards http://xkcd.com/353/

Why Python for Bioinformatics? Good with Strings Files and Formats Web and Databases Objects and Concepts BioPython Good support for bioinformatics data-formats NumPy, SciPy, Matplotlib Good support for scientific computing BCHB524 - Edwards

Programming Environment VirtualBox Virtual machine “player” Installers for Windows, iOS, Linux provided BCHB524 Linux (Fall 2016) “Appliance” (.ova) Use File -> Import Appliance in VirtualBox Account: student/password Enthought Python Distribution EPD Free 2.7 installed Python with scientific computing packages IDLE Python Editor Consistent across platforms, simple Command-line Execution BCHB524 - Edwards

Programming Environment BCHB524 - Edwards

Programming Environment BCHB524 - Edwards

Hello World! Paste “special” (Alt-V) into IDLE, save as “lec1.py” # Output Hello World to the terminal print "Hello World!" print "Hello Georgetown!" print 'Hello Everyone' BCHB524 - Edwards

Hello World! Start the terminal, type “python lec1.py” BCHB524 - Edwards

Experiment with Hello World Quotes: single or double? mixed? How to change the order of output? What does the red line do? How to change what is printed? Add or remove? What happens if you misspell print? What happens if you forget a quote? What happens if you forget a #? Do the blank lines matter? BCHB524 - Edwards

Lessons Statements are executed from top to bottom Single or double quotes – either works as long as they match Comments (#) are ignored, so use to explain Syntax error means something is wrong Sometimes the colors will help But not necessarily at the exact position indicated. Blank lines don’t matter, so use them for readability BCHB524 - Edwards

Simple Numbers # Program input cars = 100 people_per_car = 4 drivers = 30 passengers = 90 # Compute the dependent values cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * people_per_car average_people_per_car = ( drivers + passengers ) / cars_driven people_in_last_car = ( drivers + passengers - 1 ) % people_per_car + 1 # Output the results print "There are", cars, "cars available." print "There are only", drivers, "drivers available." print "There will be", cars_not_driven, "empty cars today." print "We can transport", carpool_capacity, "people today." print "We have", passengers, "to carpool today." print "We need to put about", average_people_per_car, "in each car." print "There are", people_in_last_car, "people in the last car." BCHB524 - Edwards

Experiment with Simple Numbers What names can we use to store values? What values can we store? What happens if we change a “variable” name? What happens if we change the statement order? How do we print out numbers? By themselves? What happens if we change the input values? Are there values that produce strange answers? BCHB524 - Edwards

Lessons Variables store values for later use We can use whatever name makes sense Letters, numbers, and _ Can store explicit numbers or the result of arithmetic If you change the name in one place, you have to change it everywhere. You must store a value before you use the variable. The result of math with integers is an integer BCHB524 - Edwards

Exercises Get the programming environment set up. Make sure you can run the programs demonstrated in lecture. BCHB524 - Edwards