Introduction to Python

Slides:



Advertisements
Similar presentations
RAPTOR Syntax and Semantics By Lt Col Schorsch
Advertisements

CS 100: Roadmap to Computing Fall 2014 Lecture 0.
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Python Crash Course by Monica Sweat. Python Perspective is strongly typed, interpreted language is used to define scripts (Don't even need to define a.
Introduction to Python and programming Michael Ernst UW CSE 190p Summer 2012.
Python Control of Flow.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
The if statement and files. The if statement Do a code block only when something is True if test: print "The expression is true"
CIS Computer Programming Logic
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Lists in Python.
Computer Science 101 Introduction to Programming.
If statements while loop for loop
Built-in Data Structures in Python An Introduction.
An Introduction to Python – Part II Dr. Nancy Warter-Perez.
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
9/14/2015BCHB Edwards Introduction to Python BCHB Lecture 4.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Python Basics  Values, Types, Variables, Expressions  Assignments  I/O  Control Structures.
Lists in Python List methods and functions. List methods MethodSemantics list.append(x)Adds x to the right end of list, changes original list list.sort()Sorts.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
PYTHON PROGRAMMING. WHAT IS PYTHON?  Python is a high-level language.  Interpreted  Object oriented (use of classes and objects)  Standard library.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Introduction to python programming
Web Database Programming Using PHP
CSc 120 Introduction to Computer Programing II Adapted from slides by
Containers and Lists CIS 40 – Introduction to Programming in Python
Web Database Programming Using PHP
Basic operators - strings
Lecture 10 Data Collections
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
JavaScript: Functions.
While Loops in Python.
Engineering Innovation Center
Introduction to Python
Advanced Programming Behnam Hatami Fall 2017.
Lists in Python.
Example: Finding the Mode
Use of Mathematics using Technology (Maltlab)
An Introduction to Java – Part I, language basics
PHP.
CS 100: Roadmap to Computing
Coding Concepts (Basics)
Web DB Programming: PHP
Introduction to Python
Data Types and Data Structures
Topics Sequences Introduction to Lists List Slicing
Python Primer 1: Types and Operators
INTRODUCTION TO MATLAB
Console.WriteLine(“Good luck!”);
For loops Taken from notes by Dr. Neil Moore
Topics Sequences Lists Copying Lists Processing Lists
Introduction to Computer Science
Topics Sequences Introduction to Lists List Slicing
And now for something completely different . . .
Introduction to Programming
General Computer Science for Engineers CISC 106 Lecture 03
An Introduction to STL.
CS 100: Roadmap to Computing
While Loops in Python.
Introduction to Python
Introduction to Computer Science
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Python Usman Roshan

Python Interpreter language: the Python interpreter executes each statement one at a time. No compilation or linking is required. Python programs are called scripts which are simple text files. To execute a script we pass it through the interpreter.

Data types Basic data types Collections Integer Float String Boolean (true or false) Collections Lists Dictionaries (hash tables) Sets And more…

Expressions Numeric operators such as +, -, *, /, ** Logical operators such as and and or String operators such as in, +, [], [:] String and numeric functions such as len, abs, max, and min.

Assignment name = value Examples: sequence = “ACCCATA” x = 5 y = x + 2

Lists Ordered collection of basic types Examples: Operations on lists Concatenate: list3 = list1 + list2 Access nth element: list1[n]

Dictionaries Dictionaries are like arrays, except that they are indexed by user defined keys instead of non-negative integers. Example h={‘A’:’T’, ‘C’:’G’} Operations on dictionaries Lookup: h[key]

Input and Output Input and output to files is done by creating a file object open(path, mode) Example: f = open(“myfile.txt”,”r”) f.readline()

Control structures Conditional statements if expression : statements1 else: statements2 Example max = 0 if(x > y): max = x max = y

Iteration for count in range(start,stop,step): for item in collection: statements for item in collection: do something with item

Exercises Write a Python program to Measure and print the average length of DNA sequences in a file Determine the number of matches and mismatches between two DNA sequences of equal length Read a matrix from a text file into a two dimensional array and determine the largest number in the matrix Select random rows in a two dimensional array and print them to a file