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.

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

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.
Introduction to Programming with Python Marty Stepp University of Washington Special thanks to Scott Shawcroft, Ryan Tucker,
How to Create a Java program CS115 Fall George Koutsogiannakis.
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,
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
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.
Week 2 expressions, variables, for loops Special thanks to Scott Shawcroft, Ryan Tucker, Paul Beck, Hélène Martin, Kim Todd, John Kurkowski, and Marty.
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,
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.
“Introduction to Programming With Java”
Ruby (on Rails) CSE 190M, Spring 2009 Week 1. The Players Kelly "Everyday I'm Hustlin' " Dunn Kim "Mouse" Todd Ryan "Papa T" Tucker.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
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()
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
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.
Unit 2 Expressions and variables; for loops Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
Unit 1 Basic Python programs, functions Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
Week 2 expressions, variables, for loops Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise.
Week 2 expressions, variables, for loops Special thanks to Scott Shawcroft, Ryan Tucker, Paul Beck, Hélène Martin, Kim Todd, John Kurkowski, and Marty.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
introductory lecture on java programming
A Python Tour: Just a Brief Introduction "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie.
1/10/2008. >>> About Us Paul Beck * Third quarter TA * Computer Engineering * Ryan Tucker * Second quarter TA * Computer.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
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.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Introduction to programming in java
Computer Programming Your First Java Program: HelloWorld.java.
Introduction to Programming
Chapter 1 – Introduction
Introduction to Java Import Scanner class to use in our program
The eclipse IDE IDE = “Integrated Development Environment”
Development Environment
A Python Tour: Just a Brief Introduction
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Introduction to Programming
basic Python programs, defining functions
Introduction to Programming
Intro to Java.
How to Run a Java Program
basic Python programs, defining functions
Introduction to Algorithm Design
expressions, variables, for loops
expressions, variables, for loops
Java Intro.
Introduction to Programming
Introduction to Programming with Python
Building Java Programs
CSE 142, Spring 2012 Building Java Programs Chapter 1
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
CSE 142, Winter 2014 Building Java Programs Chapter 1
Introduction to Python
How to Run a Java Program
Presentation transcript:

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 otherwise noted, this work is licensed under:

2 About Us John Kurkowski –Computer Science, Linguistics –Produces hip-hop music Best rapper alive: Nas Kim Todd –Computer Science, Math –Loves video games Will destroy you at: Guitar Hero

3 Python! Created in 1991 by Guido van Rossum (now at Google) –Named for Monty Python Useful as a scripting language –script: A small program meant for one-time use –Targeted towards small to medium sized projects Used by: –Google, Yahoo!, Youtube –Many Linux distributions –Games and apps (e.g. Eve Online)

4 Installing Python Windows: Download Python from Install Python. Run Idle from the Start Menu. Mac OS X: Python is already installed. Open a terminal and run python or run Idle from Finder. Linux: Chances are you already have Python installed. To check, run python from the terminal. If not, install from your distribution's package system. Note: For step by step installation instructions, see the course web site.

5 Interpreted Languages interpreted –Not compiled like Java –Code is written and then directly executed by an interpreter –Type commands into interpreter and see immediate results Computer Runtime Environment CompilerCode Java: ComputerInterpreterCode Python:

6 Chapter 1 Review Console output: System.out.println Methods: public static void name () {... Hello2.java public class Hello2 { public static void main(String[] args) { hello(); } public static void hello() { System.out.println("Hello, world!"); }

7 Our First Python Program Python does not have a main method like Java –The program's main code is just written directly in the file Python statements do not end with semicolons hello.py 1print "Hello, world!"

8 The Python Interpreter Allows you to type commands one-at-a-time and see results A great way to explore Python's syntax –Repeat previous command: Alt+P

9 The print Statement print " text " print (a blank line) –Escape sequences such as \" are the same as in Java –Strings can also start/end with ' swallows.py print "Hello, world!" print print "Suppose two swallows \"carry\" it together." print 'African or "European" swallows?'

10 Comments Syntax: # comment text (one line) swallows2.py # Suzy Student, CSE 142, Fall 2097 # This program prints important messages. print "Hello, world!" print # blank line print "Suppose two swallows \"carry\" it together." print 'African or "European" swallows?'

11 Functions Function: Equivalent to a static method in Java. Syntax: def name (): statement... statement –Must be declared above the 'main' code –Statements inside the function must be indented hello2.py # Prints a helpful message. def hello(): print "Hello, world!" # main (calls hello twice) hello()

12 Whitespace Significance Python uses indentation to indicate blocks, instead of {} –Makes the code simpler and more readable –In Java, indenting is optional. In Python, you must indent. hello3.py # Prints a helpful message. def hello(): print "Hello, world!" print "How are you?" # main (calls hello twice) hello()

13 Exercise Rewrite the Figures lecture program in Python. Its output: ______ / \ \ / \______/ \ / \______/ ______ / \ | STOP | \ / \______/ ______ / \

14 Exercise Solution 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 " " # main egg() cup() stop() hat()