Introduction to the JES environment and basics of Python

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Advertisements

Python: Making colors and Using Loops. Review JES command area – program area Defining/using functions specifying a sequence of steps for what the function.
Getting Started with Haskell Tim Sheard. Learning a new language Goals – Learn how to design and use data structures – Learn to write programs using the.
INTRODUCTION TO PYTHON PART 2 INPUT AND OUTPUT CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
Introduction to scripting
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Python Programming Fundamentals
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Python programming Introduction to the JES environment and basics of Python Reading: Chapters 1, 2 from “Introduction to Computing and Programming in Python”
Computer Science 101 Introduction to Programming.
Introduction to Programming with RAPTOR
CS 100 Introduction to Computing Introduction to JES Developed by Mark Guzdial, Georgia Institute of Technology, 2003–2004; modified by Robert H. Sloan.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
Please log on The. AN INTRODUCTION TO ‘Python is a high-level, general purpose programming language’ Python is one of the many programming languages.
Variables, Expressions and Statements
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
CS1315: Introduction to Media Computation Introduction to JES.
Python programming Introduction to the JES environment and basics of Python.
Python programming Using the JES picture functions and defining new functions.
CS1315: Introduction to Media Computation Introduction to JES.
Introduction to Python Lesson 2a Print and Types.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Introduction to Programming
Development Environment
Topics Designing a Program Input, Processing, and Output
CMSC201 Computer Science I for Majors Lecture 04 – Expressions
Introduction to Python
Introduction to Matlab
Topic: Python’s building blocks -> Variables, Values, and Types
Design & Technology Grade 7 Python
Guide To UNIX Using Linux Third Edition
Variables, Expressions, and IO
Basic operations in Matlab
Introduction to Programming
Chapter 2: Introduction to Programming
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 2: Introduction to Programming
Introduction to Python
Week 1 Computer Programming Year 9 – Unit 9.04
JavaScript: Introduction to Scripting
WEB PROGRAMMING JavaScript.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
Variables and Expressions
Chapter 3 – Introduction to C# Programming
Rocky K. C. Chang September 18, 2018 (Based on Zelle and Dierbach)
Introduction to Programming with Python
CHAPTER FOUR VARIABLES AND CONSTANTS
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to Value-Returning Functions: Generating Random Numbers
Topics Designing a Program Input, Processing, and Output
CSIS110 - Introduction to Computer Science
Experiment No. (1) - an introduction to MATLAB
Topics Designing a Program Input, Processing, and Output
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
12th Computer Science – Unit 5
Introduction to Computer Science
Chapter 7 - JavaScript: Introduction to Scripting
Java: Variables, Input and Arrays
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Chapter 7 - JavaScript: Introduction to Scripting
CSIS110 - Introduction to Computer Science
Introduction to Python
Introduction to Python
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to the JES environment and basics of Python Python programming Introduction to the JES environment and basics of Python Do show this live – lots of examples, live installation.

Python The programming language we will be using is called Python http://www.python.org It’s used by companies like Google, Industrial Light & Magic, Nextel, and others The kind of Python we’re using is called Jython (Java-based Python) http://www.jython.org We’ll be using a specific tool to make Python programming easier, called JES (Jython Environment for Students). JES 4.3 available as free download: http://code.google.com/p/mediacomp-jes/ URL to look at what companies use Python is in the book.

JES - Jython Environment for Students Program area - A simple editor for programs Command area Interaction with Jython

Python interaction through commands Anything you type in command area is evaluated and its value is displayed Example: >>> 5 + 3 8 >>> ‘spam’ ‘spam’ >>> “spam” >>> “spam and more spam” ‘spam and more spam’ >>> ‘spam’ + ‘spam’ ‘spamspam’ prompt

print displays the value of an expression In many cases it makes no difference whether you use print - the result gets displayed anyway. >>> print 5 + 3 8 >>> print ‘spam’ spam >>> ‘spam’ + ‘spam’ ‘spamspam’ >>> print ‘spam’ + ‘spam’ Spamspam Note: no quotes!

Command Area Editing Up/down arrows walk through command history You can edit the line at the bottom Just put the cursor at the end of the line before hitting Return/Enter.

Variables are names for data Example: a= 3 b= -1 c = 2 x = 0 f = a*x*x + b*x + c

Variables -more examples Variables of other types newsItem = “You’ve got spam!” Variables keep their value for the duration of a program or until they get a new value through a new assignment a = 3 b = a *2 + 5 a = 0 Up to this point the value of a is still 3, but then it changes to 0

Types of data Integer Floating point number Character String num = -3 answer = 62.49 Character letter = ‘5’ String note = “lol jkjk”

Python functions Python has a lot of built-in functions for general mathematical manipulation, eg: sqrt(4) - computes the square root of 4 ord(‘A’) - computes the ASCII code for character ‘A’ (i.e., a numeric code) str(4) – produces a string corresponding to a number Example: print (-b+sqrt(b*b - 4*a*c))/2*a

Special JES-Python functions JES defines some special functions for media computation

Functions in general 4 ‘a’ F(a,b) side-effects F(4, ‘a’)

Example: sqrt() 4 sqrt(a) side-effects 2

Example: showInformation() showInformation(message): message: the message to show to the user Opens a message dialog to the user showing information message showInformation(message) Pops up a new window displaying the message text

Exploring more functions The JES Functions menu has functions arranged by type - check them out! Can you find a function that inputs a number? Can you find under what category pickAFile() is listed?

Reading Chapters 1, and Sections 2.1-2.4 from “Introduction to Computing and Programming in Python” (up to page 22)