Programming Environments

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

Chapter Goals. Contents INTRODUCTION

CHAPTER INTRODUCTION. Final Draft Oct. 15, Slides by Donald W. Smith TechNeTrain.com. Copyright 2013 by John Wiley & Sons. All rights reserved.

Chapter Goals. Contents. 1.1 Computer Programs

CHAPTER INTRODUCTION

Using IDLE for

Introduction to computers and Python. Matthieu Choplin

Laboratory Exercise #0

Conditionals: More Fun with If-Then and Logic Operators

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

Objec+ves. Review. Basics of Java Syntax Java fundamentals. What are quali+es of good sooware? What is Java? How do you compile a Java program?

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++

Introduction to Python

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

Working with JavaScript

A Func'onal Introduc'on. COS 326 David Walker Princeton University

Biocompa(bility Test Request Form

ASCII Art. Introduction: Python

Introduction to Python. Fang (Cherry) Liu Ph.D. Scien5fic Compu5ng Consultant PACE GATECH

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

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

Chapter 2 Author Notes

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

Computer Hardware. Java Software Solutions Lewis & Loftus. Key Hardware Components 12/17/2013

Conditionals: More Fun with If-Then and Logic Operators (Project 5)

ICOM 4015: Advanced Programming

Condi(onals and Loops

Lecture 1. basic Python programs, defining functions

Related Course Objec6ves

Encapsula)on, cont d. Polymorphism, Inheritance part 1. COMP 401, Spring 2015 Lecture 7 1/29/2015

Introduc)on to C++ CS 16: Solving Problems with Computers I Lecture #2

Object Oriented Programming. Feb 2015

Common Loop Algorithms 9/21/16 42

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

Week - 01 Lecture - 04 Downloading and installing Python

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

Learning objec<ves. Classes, Objects, and Methods. Problem Decomposi<on. Problem Decomposi<on (cont d)

University of Texas at Arlington, TX, USA

1) Log on to the computer using your PU net ID and password.

Welcome to Python 3. Some history

Taken Out of Context: Language Theoretic Security & Potential Applications for ICS

9.2 Linux Essentials Exam Objectives

Software and Programming 1

4. Structure of a C++ program

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Chapter 1 - Introduction. Copyright 2014 by John Wiley & Sons. All rights reserved. 1

Arithmetic Expressions 9/7/16 44

Getting Started With Python Programming

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3. Installing Notepad++

Ways to implement a language

Programs are: CMPSCI 105/119/120: Programming, Flowchar<ng, and Running Program Flowcharts

Writing a Fraction Class

Table of Contents EVALUATION COPY

Java Bytecode (binary file)

Computer Programming : C++

Chapter 8 SETS AND DICTIONARIES

CMPT 100 : INTRODUCTION TO

Lecture 4: Build Systems, Tar, Character Strings

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Macro Assembler. Defini3on from h6p://

Python Input, output and variables

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Lecture 5. Defining Functions

Eclipse Environment Setup

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

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A

Return Values SECTION /26/16 Page 33

BBM 101 Introduc/on to Programming I Fall 2014, Lecture 3. Aykut Erdem, Erkut Erdem, Fuat Akal

MACRO NOTES DOCUMENTATION

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Class #1. introduction, functions, variables, conditionals

CS10001: Computer Literacy Lab Assignment #4

CSI Lab 02. Tuesday, January 21st

C++ Support Classes (Data and Variables)

Chapter 2. Editing And Compiling

Python Programming: An Introduction to Computer Science

Software Development. Integrated Software Environment

CISC327 - So*ware Quality Assurance

Episode 1 Using the Interpreter

CSC105, Introduction to Computer Science I. Introduction. Perl Directions NOTE : It is also a good idea to

CONTAINERIZING JOBS ON THE ACCRE CLUSTER WITH SINGULARITY

Part III Appendices 165

Software and Programming 1

Get It Interpreter Scripts Arrays. Basic Python. K. Cooper 1. 1 Department of Mathematics. Washington State University. Basics

UEE1302 (1102) F10: Introduction to Computers and Programming

CSSE232 Computer Architecture I. Datapath

CSCE 110: Programming I

Lesson 1: Writing Your First JavaScript

The plan. Racket will return! Lecture will not recount every single feature of Java. Final project will be wri)ng a Racket interpreter in Java.

Writing and Running Programs

Lecture 2: Memory in C

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

Crash Dive into Python

One of the hardest things you have to do is to keep track of three kinds of commands when writing and running computer programs. Those commands are:

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Programming Languages and Techniques (CIS120)

Introduction to Programming

Agenda. Excep,ons Object oriented Python Library demo: xml rpc

Transcription:

Programming Environments There are several ways of crea/ng a computer program Using an Integrated Development Environment (IDE) Using a text editor You should use the method you are most comfortable with. I ll PyCharm for all my in-class examples 9/2/16 27

IDE components The source code editor can help programming by: Lis/ng line numbers of code Color lines of code (comments, text ) Auto-indent source code Output window Debugger 9/2/16 28

The PyCharm IDE Files Editor Output 9/2/16 29

Your first program Tradi/onal Hello World program in Python We will examine this program in the next sec/on Typing the program into your IDE would be good prac/ce! Be careful of spelling e.g., print vs. primt PyTHon is CaSe SeNsI/Ve. 9/2/16 30

Text editor programming You can also use a simple text editor to write your source code Once saved as Hello.py, you can use a console window to: Compile the program Run the program Output Compile/execute 9/2/16 31

Organize your work Your source code is stored in.py files Create a folder for this course Create one folder per program inside the course folder A program can consist of several.py files Be sure you know where your IDE stores your files You need to be able to find you files Backup your files: To a USB flash drive To a network drive 9/2/16 32

Python interactive mode Like other languages you can write/save a complete Python program in a file and let the interpreter execute the instruc/ons all at once. Alterna/vely you can run instruc/ons one at a /me using interac/ve mode. It allows quick test programs to be wriben. Interac/ve mode allows you to write python statements directly in the console window 9/2/16 33

Source Code to a Running Program The compiler reads your program and generates byte code instruc/ons (simple instruc/ons for the Python Virtual machine) The Python Virtual machine is a program that is similar to the CPU of your computer Any necessary libraries (e.g. for drawing graphics) are automa/cally located and included by the virtual machine 9/2/16 34

Let s Get Started! Open the PyCharm on you lab computer We are going to start simple, and as we learn more about Python, we ll use addi/onal features in PyCharm 9/2/16 35

Hello World Type the following into the Editor: # My first Python program print( Hello World! ) Save your file as hello.py This is Step Two Write a simple program from page 7 in your text. Remember Python is case sensi(ve You have to enter the upper and lower case lebers exactly as this appear above 9/2/16 36

Analyzing Your First Program A Python program contains one or more lines of instruc/ons (statements) that will be translated and executed by the interpreter # My first Python program print( Hello World! ) The first line is a comment (a statement that provides descrip/ve informa/on about the program to programmers). The second line contains a statement that prints a line of text onscreen Hello, World! 9/2/16 37

Basic Python Syntax: Print Using the Python print() func/on. A func/on is a collec/on of programming instruc/ons that carry out a par/cular task (in this case to print a value onscreen). It s code that somebody else wrote for you! 9/2/16 38

Syntax for Python Functions To use, or call, a func/on in Python you need to specify: The name of the func/on that you want to use (in the previous example the name was print) Any values (arguments) needed by the func/on to carry out its task (in this case, Hello World! ). Arguments are enclosed in parentheses and mul/ple arguments are separated with commas. A sequence of characters enclosed in quota/ons marks are called a string 9/2/16 39

More Examples of the print Function Prin/ng numerical values print(3 + 4) Evaluates the expression 3 + 4 and displays 7 Passing mul/ple values to the func/on print( the answer is, 6 * 7) Displays The answer is 42 Each value passed to the func/on is displayed, one ajer another, with a blank space ajer each value By default the print func/on starts a new line ajer its arguments are printed print( Hello ) print( World! ) Prints two lines of text Hello World! 9/2/16 40

Our Second Program (Page 12, printtest.py) ## # Sample Program that demonstrates the print function # # Prints 7 print(3 + 4) # Print Hello World! on two lines print( Hello ) print( World! ) # Print multiple values with a single print function call print( My favorite number are, 3 + 4, and 3 + 10) # Print Hello World! on two lines print( Goodbye ) print() print( Hope to see you again ) 9/2/16 41

Errors There are two Categories of Errors: Compile-/me Errors aka Syntax Errors Spelling, capitaliza/on, punctua/on Ordering of statements, matching of parenthesis, quotes No executable program is created by the compiler Correct first error listed, then compile again. Repeat un/l all errors are fixed Run-/me Errors aka Logic Errors The program runs, but produces unintended results The program may crash 9/2/16 42

Syntax Errors Syntax error are caught by the compiler What happens if you Miss-capitalize a word: Leave out quotes Print("Hello World!") print(hello World!) Mismatch quotes print("hello World!') Don t match brackets print('hello' Type each example above in the Wing Python Shell window What error messages are generated? 9/2/16 43

Logic Errors What happens if you Divide by zero print(1/0) Misspell output print("hello, Word!") Forget to output Remove line 2 Programs will compile and run The output may not be as expected Type each example above in the PyCharm Python Shell window What error messages are generated? 9/2/16 44

Summary: Computer Basics Computers rapidly execute very simple instruc/ons A Program is a sequence of instruc/ons and decisions Programming is the art (and science) of designing, implemen/ng, and tes/ng computer programs The Central Processing Unit (CPU) performs program control and data processing Storage devices include memory and secondary storage (e.g., a USB Flash Drive) 9/2/16 45

Summary: Python Python was designed in a way that makes it easier to learn than other programming languages such as Java, C and C++. The designers goal was to give Python simpler and cleaner syntax. Set aside some /me to become familiar with the programming environment that you will use for your class work. It is important to prac/ce with the tool so you can focus on learning Python An editor is a program for entering and modifying text, such as a Python program. 9/2/16 46

Summary: Python Python is case sensi/ve. You must be careful about dis/nguishing between upper and lowercase lebers. The Python compiler translates source code into byte code instruc/ons that are executed by the Virtual machine. A func/on is called by specifying the func/on s name and its parameters. A string is a sequence of characters enclosed in quota/on marks. 9/2/16 47

Summary: Errors and pseudo code A compile-/me error is a viola/on of the programming language rules that is detected by the compiler. A run-/me error causes a program to take an ac/on that the programmer did not intend. Pseudo code is an informal descrip/on of a sequence of steps for solving a problem. An algorithm for solving a problem is a sequence of steps that is unambiguous, executable, and termina/ng. 9/2/16 48

Poll Everywhere PollEv.com/donpaberson223 9/2/16 49