1/10/2008. >>> About Us Paul Beck * Third quarter TA * Computer Engineering * Ryan Tucker * Second quarter TA * Computer.

Slides:



Advertisements
Similar presentations
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Advertisements

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.
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,
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.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
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.
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 Programming With Java”
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
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.
CS107 Introduction to Computer Science Java Basics.
COMP 171: Principles of Computer Science I John Barr.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Week 4. >>> Overview * if else * returns * input.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Python From the book “Think Python”
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
CSCI Processing CSCI Introduction to Algorithm Design An Introduction.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
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.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
introductory lecture on java programming
10/9/07 ______ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
CSC 110 – Intro to Computing - Programming
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.
8/2/07. >>> About Me Scott Shawcroft * Junior * Computer Engineering * Third Quarter TA * Creative Commons Intern * Small-time Open Source Developer
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:
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
10/16/07.
Introduction to programming in 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.
How to Run a Java Program
basic Python programs, defining functions
Introduction to Algorithm Design
Tonga Institute of Higher Education
Java Intro.
How to Run a Java Program
Introduction to Programming with Python
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
CSE 142, Spring 2012 Building Java Programs Chapter 1
CSE 142, Winter 2014 Building Java Programs Chapter 1
Presentation transcript:

1/10/2008

>>> About Us Paul Beck * Third quarter TA * Computer Engineering * Ryan Tucker * Second quarter TA * Computer Engineering & Electrical Engineering *

>>> Python Basics Interpreted Not compiled like Java This means: type commands and see results 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 Pythoninstalled. To check run python from the terminal. 2) If not, install python through your distribution's package system. Note: For step by step installation instructions, follow those provided on the course web site. Click on Python on the right hand side and follow the “Python Installation Instructions”

>>> Topic Review * 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\"!" #main hello()‏ hello.py Note: Python does not have a main method. However, methods must be defined first. Calls to methods can then be made. This is similar to having a “main” section of code. It is good practice to label this section of code with a comment. Structure: def ():...

>>> 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 \"world\"!”); } Hello.java def hello(): print "Hello \"world\"!" hello()‏ hello.py

>>> Example 1 Example: Write a method that produces the following output. We are the Knights Who Say... "Nee!" (Nee! Nee! Nee!) NO! Not the Knights Who Say "Nee"... We are the Knights Who Say... "Nee!" (Nee! Nee! Nee!)

>>> Example 1 Solution: def knights(): print "We are the Knights Who Say... \"Nee!\"" print "(Nee! Nee! Nee!)" print def poorSouls(): print "NO!\t Not the Knights Who Say \"Nee\"..." print knights() poorSouls() knights()

>>> Example 2 Example: Write a method that produces the following output. ______ / \ \ / \______/ \ / \______/ ______ / \ | STOP | \ / \______/ ______ / \

>>> Example 2 Example: Write a method that produces the following output. ______ / \ \ / \______/ \ / \______/ ______ / \ | STOP | \ / \______/ ______ / \ def egg(): top() bottom() print def cup(): bottom() line() print def stop(): top() print "| STOP |" bottom() print def hat(): top() line() print def top(): print " ______" print " / \\" def bottom(): print "\\ /" print " \\______/" def line(): print " " egg() cup() stop() hat()

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.