INTRODUCTION TO PYTHON PART 1 CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.

Slides:



Advertisements
Similar presentations
Methods Java 5.1 A quick overview of methods
Advertisements

Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Building Java Programs
1 MATH METHODS THAT RETURN VALUES. 2 JAVA'S MATH CLASS.
Computer Programming w/ Eng. Applications
Return values.
Maths & Trig, Statistical functions. ABS Returns the absolute value of a number The absolute value of a number is the number without its sign Syntax ◦
Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
Data types, declarations, and expressions in Java.
Introduction to Programming with Python Marty Stepp University of Washington Special thanks to Scott Shawcroft, Ryan Tucker,
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 2: Primitive Data and Definite Loops.
Strings, if/else, return, user input
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs with Scanner.
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 1: Introduction to Java Programming.
1 Data types, operations, and expressions Continued l Overview l Assignment statement l Increment and Decrement operators l Short hand operators l The.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Raptor Mr. Lau Ka Lun Lai King Catholic Secondary School.
INTRODUCTION TO PYTHON PART 3 - LOOPS AND CONDITIONAL LOGIC CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
INTRODUCTION TO PYTHON PART 2 INPUT AND OUTPUT CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour.
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
What is a variable?  A variable holds data in memory so the program may use that data, or store results.  Variables have a data type. int, boolean, char,
1 Introduction to Programming with Python. 2 Some influential ones: FORTRAN science / engineering COBOL business data LISP logic and AI BASIC a simple.
Computer Science 101 Introduction to Programming.
CSC 110 A 1 CSC 110 Introduction to Python [Reading: chapter 1]
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
1 Arithmetic Expressions and Built in Functions 1.ARITHMETIC OPERATORS There are five basic arithmetic operations with Fortran. These are given in the.
Fall, 2006Introduction to FORTRAN1 (2 + 2 = ???) Numbers, Arithmetic Nathan Friedman Fall, 2006.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
Introduction to Computational Linguistics Programming I.
CC112 Structured Programming Lecture 4 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Computer Science 101 Introduction to Programming.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
CSE1222: Lecture 4The Ohio State University1. Mathematical Functions (1)  The math library file cmath Yes, this is a file with definitions for common.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
CSE202: Lecture 4The Ohio State University1 Mathematical Functions.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
CPS120: Introduction to Computer Science Operations Lecture 9.
Building Java Programs Primitive Data and Definite Loops.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Introduction to Computer Science Lab 1: Numbers and Arithmetic.
Introduction to Programming with Python
1 Introduction to Programming with Python: overview.
1 Building Java Programs Chapter 2: Primitive Data and Definite Loops.
29 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Java Statements –Java Expressions –Postfix Expressions –Prefix Expressions –Evaluating.
Let’s Learn 3. Modules Saenthong School, January – February 2016
If/else, return, user input, strings
Variables, Operators, and Expressions
Fundamentals of Programming I Overview of Programming
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Introduction to Programming
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to programming with Python
4TC00 Model-based systems engineering 2.2 Types and values
Building Java Programs
Introduction to Programming Using Python PART 2
Compilers and Interpreters
Introduction to Programming with Python
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Terminal-Based Programs
Introduction to Programming with Python
Building Java Programs
Presentation transcript:

INTRODUCTION TO PYTHON PART 1 CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD

 Interpreted  Underlying code is C++  Can be used procedurally or with object-orientation  Uses indentation for subsumption of blocks  Download at python.org   Use version 2 (2.7.5 right now)  Version 3 ‘broke’ version 2 code, and many libraries have not been updated The Python Language

Programming Nomenclature and Basic Operations and Basic Operations

 Influential languages:  ForTran science / engineering  COBOL business data  LISP logic and AI  BASIC a simple language Computer Language Pedigrees

 Python was directly influenced by ABC  ABC was directly influenced by SETL Python Language Pedigree SETL ABC Python Guido Van Rossum, Python Inventor

Programming Terminology  source code: The sequence of instructions in a program.  syntax: The set of legal structures and commands that can be used in a particular programming language.  output: The messages printed to the user by a program.  console: The text box onto which output is printed.  Some source code editors pop up the console as an external window, and others contain their own console window.  Eclipse has its own console window

Compilation and Interpretation compileexecute outputsource code Hello.java byte code Hello.class interpret outputsource code Hello.py Many languages require you to compile (translate) your program into a form that the machine understands. Python is instead directly interpreted into machine instructions.

Expressions  expression: A data value or set of operations to compute a value. Examples: * 3 42  Arithmetic operators:  + - * / addition, subtraction/negation, multiplication, division  % modulus, a.k.a. remainder  ** exponentiation  precedence: Order in which operations are computed.  * / % ** have a higher precedence than * 4 is 13  Parentheses can be used to force a certain order of evaluation. (1 + 3) * 4 is 16

Integer Division  When we divide integers with /, the quotient is also an integer ) )  More examples: 35 / 5 is 7 84 / 10 is / 100 is 1  The % operator computes the remainder from a division of integers ) 14 5 )

Real Number Operations  Python can also manipulate real numbers.  Examples: e17  The operators + - * / % ** ( ) all work for real numbers.  The / produces an exact answer: 15.0 / 2.0 is 7.5  The same rules of precedence also apply to real numbers: Evaluate ( ) before * / % before + -  When integers and reals are mixed, the result is a real number.  Example: 1 / 2.0 is 0.5  The conversion occurs on a per-operator basis.  7 / 3 * / 2  2 * / 2  / 2   3.4

Mathematical Functions and Constants Command nameDescription abs( value ) absolute value ceil( value ) rounds up cos( value ) cosine, in radians floor( value ) rounds down log( value ) logarithm, base e log10( value ) logarithm, base 10 max( value1, value2 ) larger of two values min( value1, value2 ) smaller of two values round( value ) nearest whole number sin( value ) sine, in radians sqrt( value ) square root ConstantDescription e pi To use many of these commands, the top of your Python program must have the statement: from math import *

Conclusion of Python Intro Part 1 The end has come.