Review: A Computational View Programming language common concepts: 1. sequence of instructions -> order of operations important 2. conditional structures.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Character and String definitions, algorithms, library functions Characters and Strings.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
cell (letter- number) Column (letters) Row (numbers) workbook = collection of worksheets.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Files in Python Input techniques. Input from a file The type of data you will get from a file is always string or a list of strings. There are two ways.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Group practice in problem design and problem solving
Fundamentals of Python: From First Programs Through Data Structures
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Chapter 2: Variables, Operations, and Strings CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Fundamentals of Python: First Programs
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
Programming for Linguists An Introduction to Python 24/11/2011.
Lists in Python.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to Computational Linguistics Programming I.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Input, Output, and Processing
Fall Week 4 CSCI-141 Scott C. Johnson.  Computers can process text as well as numbers ◦ Example: a news agency might want to find all the articles.
If statements while loop for loop
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 7 Files.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
COSC 1P02 Introduction to Computer Science 8.1 Cosc 1P02 “For myself, I am an optimist--it does not seem to be much use being anything else.” Winston Churchill.
CMSC 202 Java Console I/O. July 25, Introduction Displaying text to the user and allowing the user to enter text are fundamental operations performed.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
ITERATION. Iteration Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Perl for Bioinformatics Part 2 Stuart Brown NYU School of Medicine.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Today… Style, Cont. – Naming Things! Methods and Functions Aside - Python Help System Punctuation Winter 2016CISC101 - Prof. McLeod1.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
ENGINEERING 1D04 Tutorial 2. What we’re doing today More on Strings String input Strings as lists String indexing Slice Concatenation and Repetition len()
7 - Programming 7J, K, L, M, N, O – Handling Data.
String and Lists Dr. José M. Reyes Álamo.
Topics Designing a Program Input, Processing, and Output
Strings CSCI 112: Programming in C.
Chapter 8 Text Files We have, up to now, been storing data only in the variables and data structures of programs. However, such data is not available.
Variables, Expressions, and IO
Introduction to Scripting
Perl for Bioinformatics
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Chapter 7 Files and Exceptions
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Topics Designing a Program Input, Processing, and Output
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
JavaScript: Objects.
Introduction to Computer Science
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
COMPUTING.
Introduction to Computer Science
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Review: A Computational View Programming language common concepts: 1. sequence of instructions -> order of operations important 2. conditional structures -> execute a group of statements based on the value of the condition(s), i.e. true or false 3. looping structures -> repeat a group of statements: for a predetermined number of times while a condition remains true until a condition becomes true

Input and Output … standard input/output input: variable = constructor (input("prompt goes here")) e.g. name = input("Enter name: ") weight = float(input("Enter package weight: ")) output (always formatted): print("string with codes".format(parameters)) e.g. print("Name is {} ".format(name)) input using formatted (customized) prompt: variable = input("str + codes".format(parameters)) e.g. count[i] = int(input(“day {}: ”.format(i)))

Input and Output … text files 1. open the file: file_variable = open(filename,mode) e.g.file_name = input("Enter file name: " ) customer_file = open(file_name, "r") sales_file = open("sales.txt", "w") 2. process the file -> next slide 3. close the file: file_variable.close() e.g.customer_file.close() sales_file.close()

Input and Output … text files read from the file (explicit): string = file_variable.readline() e.g.customer_record = customer_file.readline() typically used with a while loop: string = file_variable.readline()# priming read while string != "" and some other condition: … some code here … … that modifies the other condition …. string = file_variable.readline() … continue code here …

Input and Output … text files read from the file (implicit): for line in file_variable: e.g. for customer_record in customer_file: - the file is essentially a sequence - never use readline inside a for loop write to the file: print("string".format(parameters), file= file_variable) e.g.print( '{}'.format(items), end="", file = sales_file ) - identical to writing to the console - need to be careful of how the new line character is handled

Fundamental algorithms … I/O writing output using string format method writing sequences on separate lines, on the same line, on multiple lines by controlling the newline writing multiple lines in column justified format with column/row headers writing two dimension tables in column justified format with column/row headers reading/writing delimited (e.g. comma) data files

Fundamental Algorithms … numeric calculate an equation over a range of values (non-obvious equations will be provided) generate random numbers using the Python random library utilize constants and functions in the Python math library compute standard statistics without Python functions using a running calculation technique: count, total, average/mean, minimum, maximum read and write (formatted) one and two dimension lists of numbers

Working With Text the basic units of text: 1. Character: An individual letter, number, symbol, space, punctuation, etc. Includes visible characters and control characters in ASCII table. 2. Word: a sequence of characters delimited by the start of a line, whitespace characters (space, tab), punctuation or newline/end-of-line. 3. Line: a sequence of characters delimited by a newline or end-of-line character. 4. Field: a sequence of characters delimited by commas, tabs, spaces in a delimited file context.

Fundamental Algorithms searching is an item in the sequence? where is an item in the sequence? find the first, next, last, or all instance(s) of the item in the sequence counting all items in a sequence e.g. counting characters, words, lines, paragraphs in text; counting elements in a list counting specific items in a sequence e.g. counting occurrences of "the" in a file, how many students got 100 in the test?

Fundamental Algorithms string and substring matching find the first, next, last, and all instance(s) of the string or substring in the text e.g. "aaa" in ["abe", "555", "aaa"] "gg"in "egg" "It was" in "It was snowing yesterday. " range search does a point lie inside a given polygon? e.g. is the cell phone’s position within a repeater tower’s range does a entity with certain attributes exist? e.g. find all cereals with fiber greater than 3g and sodium less than 200mg

Fundamental Algorithms modifying a sequence: find an item insert an item replace an item delete an item combine sequences: concatenate, join, merge reformat the sequence (strings)