SOPH 303 The Digital World Term 3 Spring 2013 Notes for Week 1. Sessions 2 and 3 Revised: January 28, 2013 Aditya Mathur Head of Pillar Information Systems.

Slides:



Advertisements
Similar presentations
In the News By: Directions: Each slide has a Summary box and a Personal Thoughts box. Each box must have at least 5 sentences. Each slide also needs at.
Advertisements

Lilian Blot TO PROGRAMMING & PYTHON Introduction Autumn 2012 TPOP 1.
Lilian Blot CORE ELEMENTS PART I Python Language Autumn 2013 TPOP 1.
Programming Methodology (1). public class Hello { public static void main(String[] args) { System.out.println("Hello world"); } } Hello world.
CSci 1130 Intro to Programming in Java
Chapter Three Arithmetic Expressions and Assignment Statements
By: Things I Want to Accomplish/Do in My Life Directions: In this PowerPoint, you are going to list twenty (20) things that you want to do/accomplish in.
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
COMP 14 Introduction to Programming
Today’s lecture Review of Chapter 1 Go over homework exercises for chapter 1.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
CS 100: Roadmap to Computing Fall 2014 Lecture 0.
Lecture 2 Introduction to C Programming
Variables Pepper. Variable A variable –box –holds a certain type of value –value inside the box can change Example –A = 2B+1 –Slope = change in y / change.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Chapter 2: Introduction to C++.
Recitation 1 Programming for Engineers in Python.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Python Basic Syntax. Basic Syntax - First Program 1 All python files will have extension.py put the following source code in a test.py file. print "Hello,
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
CS 180 Problem Solving and Object Oriented Programming Fall 2010 Notes for Week 3: September 6-10, 2010 Aditya Mathur Department of Computer Science Purdue.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Copyright Curt Hill Variables What are they? Why do we need them?
Getting Started Java Fundamentals CSC207 – Software Design Summer 2011 – University of Toronto – Department of Computer Science.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Chapter 2 Variables.
Copyright © – Curt Hill Types What they do.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
9/2/2015BCHB Edwards Introduction to Python BCHB524 Lecture 1.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Fundamentals 2.
Fundamentals of Programming I Overview of Programming
Chapter 2 Variables.
Introduction to the C Language
Java Variables and Types
Introduction to Programming
Data types and variables
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
IDENTIFIERS CSC 111.
Introduction to Python
Introduction to Java, and DrJava part 1
MSIS 655 Advanced Business Applications Programming
Chapter 2 Variables.
CS 100: Roadmap to Computing
Chapter 2: Java Fundamentals
Introduction to Java, and DrJava
Introduction to Programming with Python
Chapter 2: Java Fundamentals
Unit 3: Variables in Java
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Chapter 2 Variables.
Introduction to C Programming
CS 100: Roadmap to Computing
CS Problem Solving and Object Oriented Programming Spring 2019
Introduction to Python
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

SOPH 303 The Digital World Term 3 Spring 2013 Notes for Week 1. Sessions 2 and 3 Revised: January 28, 2013 Aditya Mathur Head of Pillar Information Systems Technology and Design Singapore University of Technology and Design West Lafayette, IN, USA

Learning Objectives Week 1. Sessions 2 and 31/30/2013 Learn to use IDLE to write and execute Python programs Learn to use Python as a calculator: variables, arithmetic operations Understand basic object types: int, float, string, complex Learn how to import libraries Learn to print formatted and unformatted data Learn to use basic mathematical operations

Python installation Download Python if you have not yet done so Week 1. Sessions 2 and 31/30/2013 Source for download: Go to: http: //epd-free.enthought.com/?Download=Download+EPD+Free Click on EPD Free-Windows or EPD-Free Mac depending on your laptop When the download is complete click on the downloaded file and follow instructions to install.

Python installation: check Week 1. Sessions 2 and 31/30/2013 Go to the Enthought directory and click on IDLE. You should see a window with the message: Python |EPD_free (32-bit)| (default, Apr , 11:28:34) [GCC (Apple Inc. build 5493)] on darwin Type "copyright", "credits" or "license()" for more information. and a prompt like this: >>>

Python installation: Another check Week 1. Sessions 2 and 31/30/2013 Type: >>>import matplotlib You should see the prompt >>> indicating that matplotlib exists. More on this later.

Python: A simple exercise Week 1. Sessions 2 and 31/30/2013 Click on IDLE or just type idle in a terminal window. You should see a new window with the prompt >>> Go to the course web site and click on Sample Python Programs. Click on BasicExamplesWeek1 and then on simpleCalculator.py. Open a new window from the File menu in the Python window. Copy the code you just opened and paste in the new window.

Python: Program execution Week 1. Sessions 2 and 31/30/2013 Enter Function f5 in the new window you just opened. The program you just copied will be executed and the results will be in the Python window. Correlate the results with each line of the program to understand it. Look carefully at the comments in the program. After a small set of Python statements there will be a few simple exercises that you need to solve on your own. Once you have understood the entire program start working on problems in Problem Set 1.

Python: Types Week 1. Sessions 2 and 31/30/2013 Set of valuesSet of Operations x x x x x a b c

Python: Primitive types: int, long Week 1. Sessions 2 and 31/30/ Set of integers Set of arithmetic operators * % sys.maxint: sys.maxint-1: / // Long integers: unlimited precision Set of bitwise operators | << & >> ^ ~

Python: Primitive types: float Week 1. Sessions 2 and 31/30/ Set of floating point numbers E4 inf -inf nan Set of Operations (sample) + - * > == >= max: e+308 min: e-308 Epsilon: e-16

Python: Primitive types: complex Week 1. Sessions 2 and 31/30/2013 Set of complex numbers j 1+2j 1.3j Set of Operations (sample) + - * > == >= j

Python: Primitive types: boolean Week 1. Sessions 2 and 31/30/2013 Set of logical valuesSet of (logical) Operations (sample) and True False or not

Python: Names Week 1. Sessions 2 and 31/30/2013 Used to denote variables, classes, objects Contain characters; must start with a letter, or an underscore (_) sign or an underscore. Examples: height, area1, Dog, _great_ Length unlimited, case sensitive. Dog and dog are different names. Our convention: All class names begin with an uppercase letter; all other names begin with a lower case letter.

Python: Constants Week 1. Sessions 2 and 31/30/2013 A constant is something that cannot change during program execution. It is an immutable object. Examples: Integer constants: 0, 1, -1, +24, 29, , O14, 0x1B. 0b1011 Floating point constants: 0.0, e28, Boolean constants: True, False String constants:,, Hi!, Alice in Wonderland

Python: Variables Week 1. Sessions 2 and 31/30/2013 A variable is something whose value may change during program execution. Example: int numStudents; denotes the number of students whose grads have been processed. Its value changes as each students grade is processed by a grade processing program. Every variable has a name; its type is the type of its value. Example: hurricaneCategory=2; The name is hurricaneCategory and its type is int. The type of a variable may change when its value changes. Example: a=1 [Type of a is int] A=1.0 [Type of a changed to float]

Python: Strings and operations Week 1. Sessions 2 and 31/30/2013 A string is any sequence of Unicode characters enclosed inside double or single quotes. Examples: ``Digital world, Digital world, ``, a=Digital b= world c=a+b The value of c is Digital world Several other formatting operations are available.

Python: Expressions Week 1. Sessions 2 and 31/30/2013 Expressions are used to compute something. x=1; y=2; z=3.0 x*y+z; // Arithmetic expression, type of value float x<y; // Boolean expression, results in boolean value firstName=Mary, lastName= Jones; firstName+ +lastName; // Results in a String

Python: Assignment Week 1. Sessions 2 and 31/30/2013 An assignment statement allows assigning the value of an expression to a variable. p=x*y+z; // p gets the value of x*y+z q=x<y; // q gets the value of x<y firstName=Mary, lastName= Jones; name= firstName+ +lastName;

Week 1. Sessions 2 and Hope you enjoyed this week! Week 1. Sessions 2 and 31/30/2013