Introduction to Bioinformatics

Similar documents
Computational Expression

CSI33 Data Structures

Key Differences Between Python and Java

Computational Expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

Full file at C How to Program, 6/e Multiple Choice Test Bank

Basic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017

1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen

Introduction to Python

Typescript on LLVM Language Reference Manual

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Python - Variable Types. John R. Woodward

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

The current topic: Python. Announcements. Python. Python

Lecture 2 Tao Wang 1

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

Internet & World Wide Web How to Program, 5/e by Pearson Education, Inc. All Rights Reserved.

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

PYTHON- AN INNOVATION

Relational Operators and if. Class 10

2 nd Week Lecture Notes

Computer Programming : C++

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Chapter 2, Part III Arithmetic Operators and Decision Making

First Name: Last: ID# 1. Hexadecimal uses the symbols 1, 2, 3, 4, 5, 6, 7 8, 9, A, B, C, D, E, F,G.

Pace University. Fundamental Concepts of CS121 1

Java Bytecode (binary file)

Chapter 2: Introduction to C++

Language Reference Manual

corgi Language Reference Manual COMS W4115

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

egrapher Language Reference Manual

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Flow Control. CSC215 Lecture

BASIC ELEMENTS OF A COMPUTER PROGRAM

Flow of Control. Flow of control The order in which statements are executed. Transfer of control

V2 2/4/ Ch Programming in C. Flow of Control. Flow of Control. Flow of control The order in which statements are executed

Decision Making in C

ENGR 101 Engineering Design Workshop

CSC Web Programming. Introduction to JavaScript

Working with JavaScript

FRAC: Language Reference Manual

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

CS 106 Introduction to Computer Science I

4 Programming Fundamentals. Introduction to Programming 1 1

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

LECTURE 02 INTRODUCTION TO C++

Java+- Language Reference Manual

CMPT 125: Lecture 3 Data and Expressions

CGS 3066: Spring 2015 JavaScript Reference

Program Fundamentals

3. Java - Language Constructs I

THE IF STATEMENT. The if statement is used to check a condition: if the condition is true, we run a block

1007 Imperative Programming Part II

Python Class-Lesson1 Instructor: Yao

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Variables, Constants, and Data Types

Control of Flow. There are several Python expressions that control the flow of a program. All of them make use of Boolean conditional tests.

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

Chapter 3 Structure of a C Program

Final thoughts on functions F E B 2 5 T H

Basics of Java Programming

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Algorithms and Programming I. Lecture#12 Spring 2015

Introduction to Python (All the Basic Stuff)

Chapter 2: Basic Elements of C++

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 4 - Notes Control Structures I (Selection)

Computational Expression

Advanced Algorithms and Computational Models (module A)

Language Proposal: tail

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Full file at

Topics. Chapter 5. Equality Operators

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Chapter 2. Lexical Elements & Operators

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

3 The Building Blocks: Data Types, Literals, and Variables

DINO. Language Reference Manual. Author: Manu Jain

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University

Variables and data types

STSCI Python Introduction. Class URL

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

6. Data Types and Dynamic Typing (Cont.)

Transcription:

Introduction to Bioinformatics Variables, Data Types, Data Structures, Control Structures Janyl Jumadinova February 3, 2016

Data Type Data types are the basic unit of information storage. Instances of data types are unique (in Python). 2/19

Data Type Data types are the basic unit of information storage. Instances of data types are unique (in Python). Data stored in memory is a string of bits (0 or 1). 2/19

Data Type Data types are the basic unit of information storage. Instances of data types are unique (in Python). Data stored in memory is a string of bits (0 or 1). How the computer interprets the string of bits depends on the context. In Python, we don t need explicit declaration by specifying the type of the data. 2/19

Python Data Type These are the most basic (and most frequently used) data types: Integer: 0, 7, 13, 21, -1 Floating point: 3.14, 2.718, 1.618 String: 1, 2.718, True, None, My name is Boolean: True, False Null: None 3/19

Variables Variable is a name for a memory s location where a data value is stored. Variable Assignment assigns a value to the variable count = 0 Expression is a combination of one or more operators (+,, %,...) and operands (literals, constants, variables,...) 4/19

Input We can get data directly from the user and create an interactive program. person = raw_input( Enter your name: ) print Hello, person # age is a variable of type string age = raw_input( What is your age? ) age = int(age) # age is a variable of type int now age = age + 2 print "In two years you will be ", age, " years old." 5/19

Input We can get data directly from the user and create an interactive program. person = raw_input( Enter your name: ) print Hello, person # age is a variable of type string age = raw_input( What is your age? ) age = int(age) # age is a variable of type int now age = age + 2 print "In two years you will be ", age, " years old." print "In four years you will be ", age+2, " years old." 5/19

Input raw input() always returns a string; input() evaluates the return, so it may return a number, for example - run the following example input1= input( Enter a number: ) print type(input1), input1 input2= raw_input( Enter a number: ) print type(input2), input2 6/19

Strings in Python are created with paired single or double quotes. Strings Multi-line strings can be created by enclosing them with three single or double quotes on each end (e.g. This could span several lines ). 7/19

Strings in Python are created with paired single or double quotes. Strings Multi-line strings can be created by enclosing them with three single or double quotes on each end (e.g. This could span several lines ). The + and * operators work for strings, so help + me produces the string help me, and help * 3 produces helphelphelp. 7/19

Strings in Python are created with paired single or double quotes. Strings Multi-line strings can be created by enclosing them with three single or double quotes on each end (e.g. This could span several lines ). The + and * operators work for strings, so help + me produces the string help me, and help * 3 produces helphelphelp. String indexing: word = apple word[4] will give a letter e word[0:2] will give ap 7/19

Python Data Structures List: an ordered, zero-indexed collection of objects. For example: [1, A, 3.0] Set: an unordered collection of elements, guarantees each element is unique. For example: {1, 5, 3.0} Dictionary: an unordered collection of key/value pairs. Each key is unique. For example: {1: One, A :5, 3.0: Three } 8/19

Python Ordered Types 9/19

Python Unordered Types 10/19

Python basic language structure Newline terminates a command - no semicolon required. Indentation alone designates nested code blocks - no curly braces required. Functions, nested loops and conditionally evaluated code are all indicated using indentation. # denotes the start of a single line comment. 11/19

Basic numerical operations The +, -, *, /, % (modulo) and ** (power) all behave as expected. The = assigns the value on the right to the variable on the left. The +=, -=, *=, /= and **= perform the indicated operation between the variable on the left and the value on the right, then assign the result to the variable on the left. 12/19

Basic condition tests A == tests to see if two things have the same value.!= tests to see if two things have a different value. The <, >, <=, >= all compare relative values. An is tests to see if two things have the same identity. An in tests element membership in a collection. 13/19

Boolean algebra in Python Any value, other than None, False, 0,, or an empty collection evaluates to True in a boolean context. The boolean operators supported by python, in order of increasing precedence, are: and or not 14/19

Algorithms Any problem can be solved by an algorithm. Algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed. 15/19

Algorithms Any problem can be solved by an algorithm. Algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed. Both the actions and their order are important. 15/19

Three Groups of Control Structures 1. Sequential Structure - It is just built into the language itself. Control Structures 16/19

1. Sequential Structure 2. Selection Structures - if : single selection - if/elif/else : double or multiple selection Control Structures 17/19

Control Structures 1. Sequential Structure 2. Selection Structures 3. Repetition Structure while for 18/19

Control Structures Python programs are built from these control structures: if, while, for You implement computer algorithms by stringing sequences of these control structures together. 19/19