8/2/07. >>> About Me Scott Shawcroft * Junior * Computer Engineering * Third Quarter TA * Creative Commons Intern * Small-time Open Source Developer

Slides:



Advertisements
Similar presentations
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
Advertisements

JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Your First Java Program: HelloWorld.java
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Week 2 ______ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 1: Introduction to Java Programming.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Towson University COSC 236
CSCI 273: Processing An Introduction. Programming Languages –An abstract "human understandable" language for telling the computer what to do –The abstract.
11/27/07. >>> Overview * objects * class * self * in-object methods * nice printing * privacy * property * static vs. dynamic * inheritance.
Introduction to PythonIntroduction to Python SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Week 4. >>> Overview * if else * returns * input.
The Java Programming Language
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
Getting Started.
Week 1 basic Python programs, defining functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where.
Unit 1 Basic Python programs, functions Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
Building Java Programs Chapter 1 Introduction to Java Programming Copyright (c) Pearson All rights reserved.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
introductory lecture on java programming
1/10/2008. >>> About Us Paul Beck * Third quarter TA * Computer Engineering * Ryan Tucker * Second quarter TA * Computer.
10/9/07 ______ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Computer Science I Lab 1 ISMAIL ABUMUHFOUZ | CS 180.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
10/16/07.
Computer Programming Your First Java Program: HelloWorld.java.
Introduction to Java Import Scanner class to use in our program
The eclipse IDE IDE = “Integrated Development Environment”
Development Environment
10/9/07 ______ < Moo? > \ ^__^ \ (oo)\_______ (__)\ )\/\
Introduction to.
CSE 190D, Winter 2013 Building Java Programs Chapter 1
basic Python programs, defining functions
CompSci 230 Software Construction
Intro to Java.
Statements, Comments & Simple Arithmetic
Java Intro III.1 (Fr Feb 23).
basic Python programs, defining functions
Tonga Institute of Higher Education
Building Java Programs
Java Intro.
How to Run a Java Program
Introduction to Programming with Python
Building Java Programs
CSE 142, Summer 2012 Building Java Programs Chapter 1
Building Java Programs
CSE 142, Spring 2012 Building Java Programs Chapter 1
CSE 142, Winter 2014 Building Java Programs Chapter 1
Presentation transcript:

8/2/07

>>> About Me Scott Shawcroft * Junior * Computer Engineering * Third Quarter TA * Creative Commons Intern * Small-time Open Source Developer

>>> History – C Born 1986 – Scott Born 1991 – Python Born 1995 – Java Born

>>> Python Basics * interpreted * targeted towards short to medium sized projects * useful as a scripting language A whaa? script – short program meant for one-time use. Compute r Runtime Env CompilerCode InterpreterCode

>>> Getting it Going Windows Mac OSX Linux 1) Download Python from python.org. 2) Run 'python' using the run command. -or- Run Idle from the Start Menu. 1) Python is already installed. 2) Open a terminal and run python or run Idle from finder. 1) Chances are you already have Python installed. To check run python from the terminal. 2) If not, install python through your distribution's package system.

>>> Topic Review * cover through last week * printing - System.out.println(); * methods – public static void ()... public class Hello { public static void main(String[] args){ System.out.println("Hello world!"); } Hello.java public class Hello { public static void main(String[] args){ hello(); } public static void hello(){ System.out.println("Hello \"world\"!"); } Hello.java

>>> Missing Main print "Hello world!" hello.py public class Hello { public static void main(String[] args){ System.out.println("Hello world!"); } Hello.java The entire file is interpreted as if it was typed into the interpreter. This makes it easy to write scripts with Python.

>>> Printing public class Hello { public static void main(String[] args){ System.out.println("Hello world!"); System.out.println(); System.out.println("Suppose two " + "swallows carry it together."); } Hello.java print "Hello world!" print print "Suppose two swallows carry it together." hello.py Escape sequences: * \t – tab * \n – new line * \" - " * \\ - \

>>> Methods public class Hello { public static void main(String[] args){ hello(); } public static void hello(){ System.out.println("Hello \"world\"!"); } Hello.java def hello(): print "Hello \"world\"!" hello()‏ hello.py

>>> Whitespace Unlike in Java, in Python whitespace (think tabs and spaces) matters. Instead of using braces ({}) to designate code blocks, Python uses the indentation. This was done to promote readable code. In Java you may or may not indent and it will work. In Python you must indent. public class Hello { public static void main(String[] args){ System.out.println(); } Hello.java def hello(): print "Hello \"world\"!" def does_nothing(): pass hello()‏ hello.py

>>> Comments // This is a file full of comments. /* oooh multi-line */ Comments.java # This is a file full of comments and code. def hello(): """print 'Hello world' this comment can be multi-line""" print "Hello world" # this is in-line hello()‏ comments.py While commenting is flexible it is good practice to comment code with # comments before code in question. Comment methods with a doc string (""") on the first line in a method that way it will be used in help().

>>> help()‏ # This is a file full of comments and code. def hello(): """prints 'Hello world' this comment can be multi-line""" print "Hello world" # this is in-line hello()‏ comments.py Python can read the function comments and make them available when you need them. To access these comments call help( ). >>> hello()‏ Hello world >>> help(hello)‏ Help on function hello in module __main__: hello()‏ prints 'Hello world' this comment can be multi-line

>>> Example 1 A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget: use \" instead of " ! '' is not the same as " yossarian ~ $ python quote.py

>>> Example 2 ______ / \ \ / \______/ \ / \______/ ______ / \ | STOP | \ / \______/ ______ / \ yossarian ~ $ python quote.py // Marty Stepp, CSE 142, Autumn 2007 // This is the final version of the Figures program. // It uses static methods to capture structure and remove redundancy. // // This text is a comment. Comments let us document or explain our programs. // The Java compiler ignores comments. (They aren't printed on the console.)‏ // public class Figures3 { public static void main(String[] args) { egg(); cup(); stop(); hat(); } public static void egg() { eggTop(); System.out.println("\\ /"); System.out.println(" \\______/"); } public static void eggTop() { System.out.println(" ______"); System.out.println(" / \\"); } public static void cup() { System.out.println("\\ /"); System.out.println(" \\______/"); System.out.println(" "); } public static void stop() { eggTop(); System.out.println("| STOP |"); System.out.println("\\ /"); System.out.println(" \\______/"); } public static void hat() { System.out.println(" ______"); System.out.println(" / \\"); System.out.println(" "); }

Except where otherwise noted, this work is licensed under © 2007 Scott Shawcroft, Some Rights Reserved Python® and the Python logo are either a registered trademark or trademark of the Python Software Foundation. Java™ is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.