Introduction to Computational Linguistics Programming I.

Slides:



Advertisements
Similar presentations
Lilian Blot TO PROGRAMMING & PYTHON Introduction Autumn 2012 TPOP 1.
Advertisements

CS 100: Roadmap to Computing Fall 2014 Lecture 0.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Program Design and Development
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Lecture 2 - Variables, program execution, calculations, print() COMPSCI 101 Principles of Programming.
A First Program Using C#
Python Programming Fundamentals
Introduction to Python
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
Chapter 11 An Introduction to Visual Basic 2008 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Input, Output, and Processing
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Computer Science 101 Introduction to Programming.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students – * Office – Wheatly.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Variables, Expressions and Statements
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
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.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Introduction to Programming Python Lab 8: Loops 26 February PythonLab8 lecture slides.ppt Ping Brennan
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Computational Problem Solving Chapter 1, Sections
Introduction to Programming
Programming what is C++
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
Introduction to Programming
Introduction to Programming
Chapter 1: Introduction to computers and C++ Programming
Completing the Problem-Solving Process
Introduction to Programming
Introduction to Programming
Introduction to Programming
Variables, Expressions, and IO
Introduction to Scripting
Introduction to Programming
Introduction to Programming
Introduction to Programming
WEB PROGRAMMING JavaScript.
Introduction to Programming
CS 100: Roadmap to Computing
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
CS 1111 Introduction to Programming Spring 2019
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Introduction to Programming
Introduction to Programming
Text Copyright (c) 2017 by Dr. E. Horvath
CS 100: Roadmap to Computing
Introduction to Python
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Computational Linguistics Programming I

Resumé Algorithm: A well defined procedure for the solution of a given problem in a finite number of steps. Program: A set of instructions, written in a specific programming language, which a computer follows in solving a problem. Control Structures specify how instructions are followed

Examples of Control Structures Sequence: a series of instructions that are executed in order. Branch: an instruction involving a condition that affects the next instruction executed. Loop: for handling repeated execution. Module: a named collection of instructions that we write once but use in different contexts

Sequence

Branch

Loop

Module

Python Python is a programming language that allows us to write programs. Python programs have to obey certain syntactic conventions Python is also an interpreter, i.e. a machine which understands the conventions of the language

Python is also an Interpreter that Understands Python Programs PROGRAM WRITTEN IN PYTHON PYTHON INTERPRETER OUTPUT INPUT

Here is the World’s Simplest Python Program print “Hello World” When this program is run (interpreted) it causes “Hello World” to be printed on the screen.

Demo

The print statement The print statement consists of the word print followed by one or more arguments separated by commas: >>> print "a", "b", "c" abc In this case the arguments are strings.

Strings In Python strings are enclosed in either single quotes or double quotes. 'abc' "abc" "my name is" "Mike's name is"

Multi-line programs Here is a program consisting of a sequence of three instructions print "My name is " print "Mike" print "!"

Data Data is the raw material that programs manipulate. Data comes in different flavours called types Examples of data types are integer strings Each type of data is associated with characteristic operations.

Examples of operators Integers are associated with operators such as +, -, * etc. Using these operators we can write down complex expressions e.g. 2+2; 2-2; 2*2

Other Arithmetic Operators OperationSymbolExample Exponentiation **5 ** 2 == 25 Multiplication *2 * 3 == 6 Division /14 / 3 == 4 Remainder %14 % 3 == 2 Addition == 3 Subtraction == 1

Arithmetic expressions a number: 1 a variable: b an expression involving an operator a + 1 a complex expression a + 3*2 / 3 to eliminate ambiguity complex expressions can use parentheses (a + (3*2)) /3

Exercise 1.1 Discover the value of the following arithmetic expressions using the python interpreter 1 + 2/3 + 4 (1 + 2) / (3 + 4) 100 % % 10

Multi-line program using arithmetic expressions print "2 + 2 is", 2+2 print "3 * 4 is", 3 * 4 print , " = 100 – 1" print "(33 + 2) / = ",(33 + 2) / What is the output of this program?

Python Editor Python allows us to edit, save, check and run programs. In python shell, go to File menu. Select New Editor window appears Type program into editor window. To check or run program – go to Run menu and select check or run. You will be prompted to save file. Any filename is OK, but filename.py is best.

Exercise 1.2 Use editor to write programs that print your name and date of birth on same line on separate lines print the numbers from 0 to 4 Save the work in different files Run the programs