Jython. secondary. memory

Similar documents
Chapter 2: Introduction to Programming

Chapter 2: Introduction to Programming

Chapter 2 Writing Simple Programs

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output

SI Networked Computing: Storage, Communication, and Processing, Winter 2009

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

CSCE 110 Programming I

Getting Started with Python

Fundamentals of Programming (Python) Getting Started with Programming

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

About Variables in Python F E B 1 1 T H

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

ENGR 101 Engineering Design Workshop

Variables, expressions and statements

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Programming with Python

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

Variable and Data Type I

Basic Syntax - First Program 1

Introduction to JES and Programming. Installation

The float type and more on variables FEB 6 TH 2012

Review. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

And Parallelism. Parallelism in Prolog. OR Parallelism

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Constants. Variables, Expressions, and Statements. Variables. x = 12.2 y = 14 x = 100. Chapter

Introduction to Python, Cplex and Gurobi

Variable and Data Type I

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

Short, Unique and Mysterious

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions

Python Input, output and variables

Python Input, output and variables. Lecture 22 COMPSCI111/111G SS 2016

Variables, Expressions, and Statements

The Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1

PROGRAMMING FUNDAMENTALS

Table of Contents EVALUATION COPY

CSc 372. Comparative Programming Languages. 4 : Haskell Basics. Department of Computer Science University of Arizona

3. Java - Language Constructs I

CSCI 121: Anatomy of a Python Script

CSc 372 Comparative Programming Languages. 4 : Haskell Basics

Beyond Blocks: Python Session #1

CMSC 201 Computer Science I for Majors

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

Intro. Scheme Basics. scm> 5 5. scm>

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Try typing the following in the Python shell and press return after each calculation. Write the answer the program displays next to the sums below.

Algorithms and Data Structures

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

1. Download the JDK 6, from

Python Programming Exercises 1

Use of scanf. scanf("%d", &number);

Using System.out.println()

Chapter 3 : Informatics Practices. Class XI ( As per CBSE Board) Python Fundamentals. Visit : python.mykvs.in for regular updates

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

Python. Objects. Geog 271 Geographic Data Analysis Fall 2010

Senthil Kumaran S

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

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

Algorithms and Programming I. Lecture#12 Spring 2015

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Math Day 2 Programming: How to make computers do math for you

Datatypes, Variables, and Operations

Computer Components. Software{ User Programs. Operating System. Hardware

Java for Python Programmers. Comparison of Python and Java Constructs Reading: L&C, App B

Comp 151. More on Arithmetic and number types

Computer Components. Software{ User Programs. Operating System. Hardware

T H E I N T E R A C T I V E S H E L L

Lab 1: Course Intro, Getting Started with Python IDLE. Ling 1330/2330 Computational Linguistics Na-Rae Han

Introduction to Computer Science. Course Goals. Python. Slides02 - Intro to Python.key - September 15, 2015

Java Programming. Atul Prakash

CS1 Lecture 3 Jan. 18, 2019

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Graphing Calculator How To Packet

Introduction to Python (All the Basic Stuff)

CME 193: Introduction to Scientific Python Lecture 1: Introduction

Lecture 1. Types, Expressions, & Variables

Assessment of Programming Skills of First Year CS Students: Problem Set

Comp 151. More on Arithmetic and intro to Objects

mith College Computer Science Week 12 CSC111 Spring 2018 Dominique Thiébaut

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

Part 4 CLASSES AS ABSTRACT DATA TYPES AND INTERFACE IMPLEMENTATION. Data Structures and Algorithms 31632

Introduction to Python

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

A Type is a Set of Values. Here we declare n to be a variable of type int; what we mean, n can take on any value from the set of all integer values.

CS112 Lecture: Primitive Types, Operators, Strings

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Our Strategy for Learning Fortran 90

Lecture 8: Simple Calculator Application

Key Differences Between Python and Java

AP Computer Science A

cs1114 REVIEW of details test closed laptop period

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Transcription:

2

Jython secondary memory Jython processor Jython (main) memory 3 Jython secondary memory Jython processor foo: if Jython a<b :! (main) print a! memory else :! print b : pi : 3.141 dayofweek : tuesday 4

31 Integers -12 12 Mark Strings Barbara Ericson 85 5th Street NW 34,654.01 Floats 1.01 0.01 12.998 Pictures Inside the computer, these are all just bits 5 = name = expression foo: if a<b :! print a! else :! print b : foo: if a<b :! print a! else :! print b x = 43 : x: 43 dayofweek: tuesday pi : 3.141 pi : 3.141 dayofweek: tuesday 6

Names can be (nearly) whatever we want Must start with a letter or the _ character then, any combination of alphanumerical characters, plus the _ character Case matters Print is not the same as print mypicture is not the same as mypicture Be careful not to use Jython names as your own names Jython reserved words and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, lambda, not, or, pass, print, raise, return, try, while, yield 7 JES: Jython Environment for Students Installing JES and starting it up Go to http://code.google.com/p/mediacomp-jes/ and get the version of JES for your computer. If you know that you have a Java compiler (e.g., a JDK or an IDE ) Windows users: Just copy the folder Double-click JES application If trouble, try jes2.bat or jes-customjava.bat Mac users: Just copy the folder Double-click JES application 8

A simple editor (for entering in our programs or recipes): We ll call that the program area A command area for entering in commands for Python to execute. Program Area you are invited to use the Help menu lots of excellent help Command Area 9 JES with help displayed use the Window Layout menu to get the view you want 10

Python program + Python interpreter input data Computer Result(s) Java program input data Java compiler Computer ML program input data ML program Computer Result(s) 11 each time you write a command/expression in the command area and hit the <return> key, the Python interpreter executes/evaluates it think of it as a calculator always ready to run starting JES the >>> prompt examples of expression evaluation examples of variables creation and use 12

evaluating simple expressions try them with the JES interpreter >>> 34 + 56" >>> 34.1/46.5" >>> 22 * 33" >>> 14-15" Adding integers Dividing floats Multiplying integers Subtracting integers >>> "Hello" + "Mark"" Adding (concatenating) two strings 13 expressions with variables try again >>> value = 12 >>> value * 3 >>> value Defining a variable with integer value Using a variable in an expression The variable value does not change!!! >>> name = "Mark" >>> name * 3 Defining a variable with string value Using a variable in an expression >>> value = 20 >>> value * 3 >>> value = John It is only the = command that does change a variable value We can even change the type of value associated with a name >>> x = 10" >>> x = x - 3" What does it mean? 14

15 Names References Objects >>> a = 3" >>> b = a" >>> a = a+2" >>> a = ʻspamʼ" a" 3" b" 5" ʻspamʼ" 16

another Python command :! print expression >>> x = 20! >>> x + 3! >>> print x + 3! >>> name = ʻMaryʼ! >>> 2*name! >>> print 2*name! >>> expression makes Python evaluating it and displaying the Python internal representation of its value >>> print expression makes Python evaluating it and displaying the Python printable (external) representation of its value often the two look identical, but sometimes not" e.g., for strings " 17 math may be surprising sometimes try! >>> print 1.0/2.0! >>> print 1/2! if you only use integers (numbers without decimal point), Jython thinks you only want integers" caution : it works a bit differently with Python 3.x" trying new expressions >>> x = ʻAnneʼ! >>> y = ʻBobʼ! >>> print x/2! what do you expect to happen? >>> print x*y! 18

data type : a fundamental concept in computer science! building blocks data: integers ( 3, -47, 105, ) reals (0.482, -21.004, 5.0, ) strings ('bbbb', 'Mark', 'A door', ) operators: arithmetic (+, -, *, %, ) string (+, *, count, ) connected to each other by the data type concept 19! numbers strings (and more )" " -3 0.314 'spam' '$'!! data 45 23.2 'F' Guido s!!!!!!!!!! + - * /! + * count! % **!! replace! operators set of values + set of primitive operators = data type Python is a strongly typed language operators of a type can be applied ONLY to data belonging to that type Python raises an error in case of mismatching data and operators 20

functional definition of operators general form: op : dom x dom x dom some of these operators are expressed in infix notation, other in functional notation numbers (int and float) + : num x num num - : num x num num * : num x num num / : num x num num ** : num x num num % : num x num num abs : num num 21 functional definition of operators general form: op : dom x dom x dom strings some of these operators are expressed in infix notation, other in functional notation + : string x string string * : string x int string or * : int x string string count : string x string int find : string x string int 22