CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

Size: px
Start display at page:

Download "CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output"

Transcription

1 CSCE 110 Programming Basics of Python: Variables, Expressions, and nput/output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Fall 2011

2 Python Python was developed in 1989 by Guido van Rossum in the Netherlands. Python was released for public distribution in early How did Python begin? van Rossum was having a hard time getting the job done with the existing tools available. He envisioned that there was an easier way to get things done. While Python has been around for over 15 years, Python is still relatively new to general software development. However, it has a lot of a lot of support from the community and new users are finding themselves programming in Python (and loving it) everyday.

3 Be an Explorer Since you are learning a new language, it is very important that you experiment with the material. Be curious about trying different things. Don t be afraid to make a mistake or crash your computer. That s how we learn best.

4 Python Distribution Used in this Course n my opinion, the easiest way to get Python (and the most popular modules) is to use the Enthought Python Distribution (EPD). t s free for academic use! t s available for the major operating systems: Windows, Mac, and Linux t s what s installed on the lab machines. Here s the URL if you want to install it on your personal computer. At the time of this writing, EPD uses version 2.7 of Python. We will not cover any nuances associated with Python 3.x in this course.

5 WingWare DE 101 Now that we have a Python distribution, we need a way to type in our code. We will use WingWare DE 101 in this course. t s free for academic use! t s available for the major operating systems: Windows, Mac, and Linux t s what s installed on the lab machines. Here s the URL if you want to install it on your personal computer. binaries

6 Now, we are ready to start programming! We will take it slow and easy in the beginning. want you to get comfortable getting acquainted with the basics. Following along in class is not enough. You MUST type in the programs on your computer and see how they work. You MUST type in the programs so that if you make a mistake you can learn how to make the appropriate correction. You MUST type in the programs because programming promotes active (and not passive) learning.

7 nteractive Execution in the Python Shell

8 Hello, World! Python s print statement is the tool for displaying program output to your users. Type the following in the command-line editor. > > > print Hello, World!

9 Using Python as a Calculator > > > > > > 15 / 3 > > > 12 *

10 Operators Mathematical operators: +, -, *, /, %, ** addition (+) subtraction (-) multiplication (*) division (/) modulus or remainder (%) exponenentiation (**) Comparision operators: <, <=, >, >=, ==,!= strictly less than (<) less than or equal to (<=) strictly greater than (>) greater than or equal to (>=) equal to (==) not equal to (!=) Expression conjunctive operators: and, or, not

11 Variables and Assignment > > > counter = 0 > > > miles = > > > name = Bob > > > counter = counter + 1 > > > kilometers = * miles > > > print miles > > > print counter 1 > > > print kilometers

12 Variables Variables are the set of valid strings that are allowed as names in a computer language such as Python. The rules for forming Python variables are: First character must be a letter or underscore (_) Any additional characters can be alphanumeric or underscore Case-sensitive No variables can begin with a number. No symbols other than alphanumerics or underscores are ever allowed. No variable can be the same as keywords, which form the foundation of the language.

13 Keywords and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield

14 Numbers Python supports five basic numerical types. int (signed integers) long (long integers) bool (Boolean values) float (floating point real numbers) complex (complex numbers) Here are some examples. int: long: l L bool: True False float: complex: j J 0+1j

15 Strings Strings are a contiguous set of characters in between quotation marks. Strings are immutable sequences. A program can refer to elements or subsequences of strings. However, strings cannot be modified in place. Python allows for either pairs of single or double quotes. Triple quotes (three consecutive single or double quotes) can be used to escape special characters. Subsets of strings can be taken using the index ( [ ] )and slice ( [ : ] )operators,whichworkwithindexesstarting at 0 in the beginning of the string and working their way from -1 at the end. Slice ( [] ) gives the character from the given index or location Range slice ( [x:y] ) gives the characters starting at index x and ending at index y -1 The plus ( + )signisthestringconcatenationoperator. The asterisk ( * )istherepetitionoperator.

16 String Examples > > > string = "Texas A&M University" > > > string[0] T > > > string[2:5] xas > > > string[4:] s A&M University > > > string[:6] Texas > > > string * 2 Texas A&M UniversityTexas A&M University > > > string = t\ s a girl! > > > string "t s a girl!"

17 Writing Python Programs

18 User nput 1. Type the following text directly into your editor. > > > name = raw_input("please enter your name: ") > > > print "Hello", name, "- good to see you!" 2. Type the above text into a file called hello.py and save it as hello.py. Afterward, run the program. 3. Discuss the difference between the two different approaches for entering Python programs.

19 Write the Following Python Programs 1. Full name greeting. Write a program that asks for a person s first name, then middle, and then last. Afterwards, it should greet the person using their full name. 2. Guessing game? Write a program that asks a person to guess anumber.add1totheguessednumber,andthensuggest that their guess was close to being correct. 3. Guessing game (version 2)? Write a program that asks a person to guess a number. Tell the user that their guess was off by a random amount.

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

Welcome to Introduction to programming in Python

Welcome to Introduction to programming in Python Welcome to Introduction to programming in Python Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 14, Jan 21, Jan 28, Feb 11 Welcome Fire exits Toilets Refreshments 1 Learning objectives of the course An

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

Chapter 2 Writing Simple Programs

Chapter 2 Writing Simple Programs Chapter 2 Writing Simple Programs Charles Severance Textbook: Python Programming: An Introduction to Computer Science, John Zelle Software Development Process Figure out the problem - for simple problems

More information

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing. Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 8 Python Due by Oct 26 th 5:00am Endianness Lab 9 Tuesday Due by Nov 2 nd 5:00am Network programming

More information

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie "Computers

More information

River Dell Regional School District. Computer Programming with Python Curriculum

River Dell Regional School District. Computer Programming with Python Curriculum River Dell Regional School District Computer Programming with Python Curriculum 2015 Mr. Patrick Fletcher Superintendent River Dell Regional Schools Ms. Lorraine Brooks Principal River Dell High School

More information

Outline Basic concepts of Python language

Outline Basic concepts of Python language Data structures: lists, tuples, sets, dictionaries Basic data types Examples: int: 12, 0, -2 float: 1.02, -2.4e2, 1.5e-3 complex: 3+4j bool: True, False string: "Test string" Conversion between types int(-2.8)

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman LEARNING TO PROGRAM WITH PYTHON Richard L. Halterman Copyright 2011 Richard L. Halterman. All rights reserved. i Contents 1 The Context of Software Development 1 1.1 Software............................................

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

Introduction to Python

Introduction to Python Introduction to Python Sophia Bethany Coban Problem Solving By Computer March 26, 2014 Introduction to Python Python is a general-purpose, high-level programming language. It offers readable codes, and

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 11 Network Programming Due by Dec 1 st 5:00am Python Lab 12 Next Week Due by Dec 8 th 5:00am

More information

Python Basics. S.R. Doty. August 27, 2008. 1 Preliminaries 4 1.1 What is Python?... 4 1.2 Installation and documentation... 4

Python Basics. S.R. Doty. August 27, 2008. 1 Preliminaries 4 1.1 What is Python?... 4 1.2 Installation and documentation... 4 Python Basics S.R. Doty August 27, 2008 Contents 1 Preliminaries 4 1.1 What is Python?..................................... 4 1.2 Installation and documentation............................. 4 2 Getting

More information

Invent Your Own Computer Games with Python

Invent Your Own Computer Games with Python Invent Your Own Computer Games with Python 2nd Edition Al Sweigart Copyright 2008, 2009, 2010 by Albert Sweigart Some Rights Reserved. "Invent Your Own Computer Games with Python" ("Invent with Python")

More information

Computer Science for San Francisco Youth

Computer Science for San Francisco Youth Python for Beginners Python for Beginners Lesson 0. A Short Intro Lesson 1. My First Python Program Lesson 2. Input from user Lesson 3. Variables Lesson 4. If Statements How If Statements Work Structure

More information

Hands-On Python A Tutorial Introduction for Beginners Python 3.1 Version

Hands-On Python A Tutorial Introduction for Beginners Python 3.1 Version Hands-On Python A Tutorial Introduction for Beginners Python 3.1 Version Dr. Andrew N. Harrington Computer Science Department, Loyola University Chicago Released under the Creative commons Attribution-Noncommercial-Share

More information

CSC 221: Computer Programming I. Fall 2011

CSC 221: Computer Programming I. Fall 2011 CSC 221: Computer Programming I Fall 2011 Python control statements operator precedence importing modules random, math conditional execution: if, if-else, if-elif-else counter-driven repetition: for conditional

More information

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running

More information

Computer Programming Tutorial

Computer Programming Tutorial Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Practical Programming, 2nd Edition

Practical Programming, 2nd Edition Extracted from: Practical Programming, 2nd Edition An Introduction to Computer Science Using Python 3 This PDF file contains pages extracted from Practical Programming, 2nd Edition, published by the Pragmatic

More information

Introduction to Python

Introduction to Python 1 Daniel Lucio March 2016 Creator of Python https://en.wikipedia.org/wiki/guido_van_rossum 2 Python Timeline Implementation Started v1.0 v1.6 v2.1 v2.3 v2.5 v3.0 v3.1 v3.2 v3.4 1980 1991 1997 2004 2010

More information

Python. KS3 Programming Workbook. Name. ICT Teacher Form. Do you speak Parseltongue?

Python. KS3 Programming Workbook. Name. ICT Teacher Form. Do you speak Parseltongue? Python KS3 Programming Workbook Do you speak Parseltongue? Name ICT Teacher Form Welcome to Python The python software has two windows that we will use. The main window is called the Python Shell and allows

More information

Introduction to Computer Science I Spring 2014 Mid-term exam Solutions

Introduction to Computer Science I Spring 2014 Mid-term exam Solutions Introduction to Computer Science I Spring 2014 Mid-term exam Solutions 1. Question: Consider the following module of Python code... def thing_one (x): y = 0 if x == 1: y = x x = 2 if x == 2: y = -x x =

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Beginning to Program Python

Beginning to Program Python COMP1021 Introduction to Computer Science Beginning to Program Python David Rossiter Outcomes After completing this presentation, you are expected to be able to: 1. Use Python code to do simple text input

More information

Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

More information

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to Chapter 3 Writing Simple Programs Charles Severance Unless otherwise noted, the content of this course material is licensed under a Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/.

More information

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to help you to better understand functions:

More information

Number Representation

Number Representation Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

More information

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March 2011. Overview/Questions

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March 2011. Overview/Questions CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic Aaron Stevens 28 March 2011 1 Overview/Questions Review: Programmability Why learn programming? What is a programming language?

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...

More information

Tokens and Python s Lexical Structure

Tokens and Python s Lexical Structure Chapter 2 Tokens and Python s Lexical Structure The first step towards wisdom is calling things by their right names. Chinese Proverb Chapter Objectives ˆ Learn the syntax and semantics of Python s five

More information

Writing Simple Programs

Writing Simple Programs Chapter 2 Writing Simple Programs Objectives To know the steps in an orderly software development process. To understand programs following the Input, Process, Output (IPO) pattern and be able to modify

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

6.170 Tutorial 3 - Ruby Basics

6.170 Tutorial 3 - Ruby Basics 6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you

More information

COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9

COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9 COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9 1 HOW WAS YOUR WEEKEND? Image source: http://www.liverunsparkle.com/ its-a-long-weekend-up-in-here/ 1. Read and Post on Piazza 2. Installed JDK &

More information

An introduction to Python for absolute beginners

An introduction to Python for absolute beginners An introduction to Python for absolute beginners Bob Dowling University Information Services scientific-computing@ucs.cam.ac.uk http://www.ucs.cam.ac.uk/docs/course-notes/unix-courses/pythonab 1 Welcome

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand: Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Computer Science 1 CSci 1100 Lecture 3 Python Functions

Computer Science 1 CSci 1100 Lecture 3 Python Functions Reading Computer Science 1 CSci 1100 Lecture 3 Python Functions Most of this is covered late Chapter 2 in Practical Programming and Chapter 3 of Think Python. Chapter 6 of Think Python goes into more detail,

More information

Introduction to Python for Text Analysis

Introduction to Python for Text Analysis Introduction to Python for Text Analysis Jennifer Pan Institute for Quantitative Social Science Harvard University (Political Science Methods Workshop, February 21 2014) *Much credit to Andy Hall and Learning

More information

Computational Mathematics with Python

Computational Mathematics with Python Boolean Arrays Classes Computational Mathematics with Python Basics Olivier Verdier and Claus Führer 2009-03-24 Olivier Verdier and Claus Führer Computational Mathematics with Python 2009-03-24 1 / 40

More information

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

More information

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

More information

Java Crash Course Part I

Java Crash Course Part I Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

More information

Government Girls Polytechnic, Bilaspur

Government Girls Polytechnic, Bilaspur Government Girls Polytechnic, Bilaspur Name of the Lab: Internet & Web Technology Lab Title of the Practical : Dynamic Web Page Design Lab Class: CSE 6 th Semester Teachers Assessment:20 End Semester Examination:50

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 3 A First MaSH Program In this section we will describe a very

More information

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn 2009. Claus Führer Simulation Tools Automn 2009 1 / 65

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn 2009. Claus Führer Simulation Tools Automn 2009 1 / 65 Simulation Tools Python for MATLAB Users I Claus Führer Automn 2009 Claus Führer Simulation Tools Automn 2009 1 / 65 1 Preface 2 Python vs Other Languages 3 Examples and Demo 4 Python Basics Basic Operations

More information

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode.

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode. Last time we... [1] Learned how to set up our computer for scripting with python et al. [2] Thought about breaking down a scripting problem into its constituent steps. [3] Solved a simple data logistics

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

a high-level language that translate a set of instructions into! )!<24<=.'8'.!.)$4#)4'!,<),!,&)$*.),'!)!*',!->!2$*,&#?,2-$*!2$,-!5)?<2$'!

a high-level language that translate a set of instructions into! )!<24<=.'8'.!.)$4#)4'!,<),!,&)$*.),'!)!*',!->!2$*,&#?,2-$*!2$,-!5)?<2$'! Python!"#$%&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"#$%!"&''%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!()*+!,-!.')&$/!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&')0!)$0!1&2,'%

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

PIC 10A. Lecture 7: Graphics II and intro to the if statement

PIC 10A. Lecture 7: Graphics II and intro to the if statement PIC 10A Lecture 7: Graphics II and intro to the if statement Setting up a coordinate system By default the viewing window has a coordinate system already set up for you 10-10 10-10 The origin is in the

More information

Udacity cs101: Building a Search Engine. Extracting a Link

Udacity cs101: Building a Search Engine. Extracting a Link Udacity cs101: Building a Search Engine Unit 1: How to get started: your first program Extracting a Link Introducing the Web Crawler (Video: Web Crawler)... 2 Quiz (Video: First Quiz)...2 Programming (Video:

More information

Computational Mathematics with Python

Computational Mathematics with Python Computational Mathematics with Python Basics Claus Führer, Jan Erik Solem, Olivier Verdier Spring 2010 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring 2010 1

More information

Python Lists and Loops

Python Lists and Loops WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show

More information

PHP Tutorial From beginner to master

PHP Tutorial From beginner to master PHP Tutorial From beginner to master PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.

More information

2/1/2010. Background Why Python? Getting Our Feet Wet Comparing Python to Java Resources (Including a free textbook!) Hathaway Brown School

2/1/2010. Background Why Python? Getting Our Feet Wet Comparing Python to Java Resources (Including a free textbook!) Hathaway Brown School Practical Computer Science with Preview Background Why? Getting Our Feet Wet Comparing to Resources (Including a free textbook!) James M. Allen Hathaway Brown School jamesallen@hb.edu Background Hathaway

More information

Python Loops and String Manipulation

Python Loops and String Manipulation WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

More information

Financial Accounting Tutorial

Financial Accounting Tutorial Financial Accounting Tutorial About the Tutorial Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985-1990.

More information

Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13

Invitation to Ezhil : A Tamil Programming Language for Early Computer-Science Education 07/10/13 Invitation to Ezhil: A Tamil Programming Language for Early Computer-Science Education Abstract: Muthiah Annamalai, Ph.D. Boston, USA. Ezhil is a Tamil programming language with support for imperative

More information

Today s Topics... Intro to Computer Science (cont.) Python exercise. Reading Assignment. Ch 1: 1.5 (through 1.5.2) Lecture Notes CPSC 121 (Fall 2011)

Today s Topics... Intro to Computer Science (cont.) Python exercise. Reading Assignment. Ch 1: 1.5 (through 1.5.2) Lecture Notes CPSC 121 (Fall 2011) Today s Topics... Intro to Computer Science (cont.) Python exercise Reading Assignment Ch 1: 1.5 (through 1.5.2) S. Bowers 1 of 8 Computation (cont.) What parts do recipes usually have? A description (the

More information

Introduction to Computers and Programming

Introduction to Computers and Programming M01_GADD7119_01_SE_C01.QXD 1/30/08 12:55 AM Page 1 CHAPTER 1 Introduction to Computers and Programming TOPICS 1.1 Introduction 1.2 Hardware and Software 1.3 How Computers Store Data 1.4 How a Program Works

More information

NLP Programming Tutorial 0 - Programming Basics

NLP Programming Tutorial 0 - Programming Basics NLP Programming Tutorial 0 - Programming Basics Graham Neubig Nara Institute of Science and Technology (NAIST) 1 About this Tutorial 14 parts, starting from easier topics Each time: During the tutorial:

More information

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is

More information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Python Programming: An Introduction to Computer Science Chapter 7 Decision Structures Python Programming, 1/e 1 Objectives To understand the programming pattern simple decision and its implementation using

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Python Programming: An Introduction to Computer Science Sequences: Strings and Lists Python Programming, 2/e 1 Objectives To understand the string data type and how strings are represented in the computer.

More information

Programming a mathematical formula. INF1100 Lectures, Chapter 1: Computing with Formulas. How to write and run the program.

Programming a mathematical formula. INF1100 Lectures, Chapter 1: Computing with Formulas. How to write and run the program. 5mm. Programming a mathematical formula INF1100 Lectures, Chapter 1: Computing with Formulas Hans Petter Langtangen We will learn programming through examples The first examples involve programming of

More information

Introduction to Visual C++.NET Programming. Using.NET Environment

Introduction to Visual C++.NET Programming. Using.NET Environment ECE 114-2 Introduction to Visual C++.NET Programming Dr. Z. Aliyazicioglu Cal Poly Pomona Electrical & Computer Engineering Cal Poly Pomona Electrical & Computer Engineering 1 Using.NET Environment Start

More information

Python 3 Programming. OCR GCSE Computing

Python 3 Programming. OCR GCSE Computing Python 3 Programming OCR GCSE Computing OCR 2012 1 Contents Introduction 3 1. Output to the screen 5 2. Storing Data in Variables 6 3. Inputting Data 8 4. Calculations 9 5. Data Types 10 6. Selection with

More information

ESPResSo Summer School 2012

ESPResSo Summer School 2012 ESPResSo Summer School 2012 Introduction to Tcl Pedro A. Sánchez Institute for Computational Physics Allmandring 3 D-70569 Stuttgart Germany http://www.icp.uni-stuttgart.de 2/26 Outline History, Characteristics,

More information

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies: Exercise 0 Deadline: None Computer Setup Windows Download Python(x,y) via http://code.google.com/p/pythonxy/wiki/downloads and install it. Make sure that before installation the installer does not complain

More information

Solving Quadratic Equations by Factoring

Solving Quadratic Equations by Factoring 4.7 Solving Quadratic Equations by Factoring 4.7 OBJECTIVE 1. Solve quadratic equations by factoring The factoring techniques you have learned provide us with tools for solving equations that can be written

More information

Getting started with the Stata

Getting started with the Stata Getting started with the Stata 1. Begin by going to a Columbia Computer Labs. 2. Getting started Your first Stata session. Begin by starting Stata on your computer. Using a PC: 1. Click on start menu 2.

More information

Computer Science 217

Computer Science 217 Computer Science 217 Midterm Exam Fall 2009 October 29, 2009 Name: ID: Instructions: Neatly print your name and ID number in the spaces provided above. Pick the best answer for each multiple choice question.

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Introduction to the course, Eclipse and Python

Introduction to the course, Eclipse and Python As you arrive: 1. Start up your computer and plug it in. 2. Log into Angel and go to CSSE 120. Do the Attendance Widget the PIN is on the board. 3. Go to the Course Schedule web page. Open the Slides for

More information

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID:

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID: CS177 MIDTERM 2 PRACTICE EXAM SOLUTION Name: Student ID: This practice exam is due the day of the midterm 2 exam. The solutions will be posted the day before the exam but we encourage you to look at the

More information

Windows PowerShell Essentials

Windows PowerShell Essentials Windows PowerShell Essentials Windows PowerShell Essentials Edition 1.0. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights

More information

Introduction to. Marty Stepp (stepp@cs.washington.edu) University of Washington

Introduction to. Marty Stepp (stepp@cs.washington.edu) University of Washington Introduction to Programming with Python Marty Stepp (stepp@cs.washington.edu) University of Washington Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except

More information

Computer Programming I & II*

Computer Programming I & II* Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware

More information

Just Enough Python. version 2.0, 20 August 2015, 2015 by Jon Seger Department of Biology, University of Utah, Salt Lake City, UT 84112

Just Enough Python. version 2.0, 20 August 2015, 2015 by Jon Seger Department of Biology, University of Utah, Salt Lake City, UT 84112 Just Enough Python version 2.0, 20 August 2015, 2015 by Jon Seger Department of Biology, University of Utah, Salt Lake City, UT 84112 1. Prolog: Why program, and why in Python? 1 2. First steps 4 2.1 Installing

More information

Homework 2. A 4*4 image with 16 pixels Borders unaltered. Color of B2 = Average color of (B1,A2,B3,C2) A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4

Homework 2. A 4*4 image with 16 pixels Borders unaltered. Color of B2 = Average color of (B1,A2,B3,C2) A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 Homework 2 A 4*4 image with 16 pixels Borders unaltered A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 Color of B2 = Average color of (B1,A2,B3,C2) Swap function Example: (swap_buggy.py) >>> a = 1...

More information

Variables, Constants, and Data Types

Variables, Constants, and Data Types Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class: L&L, 2.1-2.3, App C 1 Primitive Data There are eight

More information

Programming Languages CIS 443

Programming Languages CIS 443 Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

More information

Outline. multiple choice quiz bottom-up design. the modules main program: quiz.py namespaces in Python

Outline. multiple choice quiz bottom-up design. the modules main program: quiz.py namespaces in Python Outline 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall

More information

Computational Mathematics with Python

Computational Mathematics with Python Numerical Analysis, Lund University, 2011 1 Computational Mathematics with Python Chapter 1: Basics Numerical Analysis, Lund University Claus Führer, Jan Erik Solem, Olivier Verdier, Tony Stillfjord Spring

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information