ICAPRG301A Week 2 Strings and things Charles Babbage 1791 - 1871 Developed the design for the first computer which he called a difference engine, though.

Slides:



Advertisements
Similar presentations
Lecture 9: More on objects, classes, strings discuss hw3 assign hw4 default values for variables scope of variables and shadowing null reference and NullPointerException.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
Introduction to Python
Adapted from Dr. Craig Chase, The University of Texas at Austin.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Introduction to Python and programming Michael Ernst UW CSE 190p Summer 2012.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Line Continuation, Output Formatting, and Decision Structures CS303E: Elements of Computers and Programming.
Intro to Programming Problem 1: Computers have to be told exactly what do to. Problem 2: Computers only understand “Machine language”. Problem 3: Machine.
Introduction to Python
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Charles Babbage Invented the first computer (depending on what you consider a computer to be). On two occasions I have been asked by members.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Variables and Expressions CMSC 201 Chang (rev )
Week 9 - Monday.  What did we talk about last time?  Time  GDB.
CS 177 Week 4 Recitation Slides Variables, Files and Functions.
Introduction to Python and programming Ruth Anderson UW CSE 140 Winter
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Chapter 2 Variables.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
Charles Babbage Invented the first computer (depending on what you consider a computer is). On two occasions I have been asked by members of.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
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.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
1 2. Program Construction in Java. 01 Java basics.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Input, Output and Variables GCSE Computer Science – Python.
Week 2 - Wednesday CS 121.
Chapter 2 Variables.
Building Java Programs
Documentation Need to have documentation in all programs
Multiple variables can be created in one declaration
Variables and Primative Types
Computer Programming Methodology Introduction to Java
Lesson 2: Building Blocks of Programming
Building Java Programs Chapter 2
Functions and Procedures
Building Java Programs
Statements and expressions - java
Building Java Programs
Recap Week 2 and 3.
Building Java Programs Chapter 2
Variables In today’s lesson we will look at: what a variable is
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Chapter 2 Variables.
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Building Java Programs
Class code for pythonroom.com cchsp2cs
Week 9 - Monday CS222.
Getting Started in Python
Presentation transcript:

ICAPRG301A Week 2 Strings and things Charles Babbage Developed the design for the first computer which he called a difference engine, though he never built it. This has now been built based upon his design. He also worked on a more advanced model called the Analytical Engine with another computing pioneer Ada Lovelace. However the design was never completed. On two occasions I have been asked [by members of Parliament]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question - Charles Babbage ICAPRG301A Apply introductory programming techniques

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Variables Read the notes carefully Variable are words used in a program to stand for data Useful when we don’t know the exact data or it will change Can be various types of numbers (Integer, Float etc), words (called Strings), booleans (True or False) etc Variable have scope, which means they exist in certain places In Python variables only exist once they have been given a value

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Variables types Numbers (Integers, Decimals, Money, Time, Binary) In Python we have int and float as the main number variables Text (Strings, characters) In Python we mainly use Strings Boolean (True or False) In Python we use the key words True, False. It also has a key word None which is used to show a variable is empty ArrayIn Python we use List as the major array, but there is also Dictionary, Set List Comprehension, Generator etc There are 10 types of people, those who understand binary, and those who don’t

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Variables assignment a = 5 in Python this sets the variable a to the value of 5 b = a in Python this sets the variable b to the value of 5 b= b + 5 in Python this is worked out by first calculating the right hand side and then assigning it to the left hand side c = d + bin Python this will throw an error because the variable d does not yet have a value In all these examples a single equal sign means assignment. A computer is a literal beast: it will do exactly what it thinks you told it to do. Unfortunately, that is not necessarily what you think you told it to do.

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Variables scope a= 5 def double(x): a = x + x double (a) print (a) Consider this code what will it print? 1.a Throw an error

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Lists Special type of variable, called Arrays in some languages Each list contain elements, these elements can be ordinary variables or other lists Declared like any variable but list is surrounded by [] and elements separated by, eg list = [1,’hello’, [‘a’,’b’,’c’], True] Accessed by using slicing

ICAPRG301A Week 2Strings and things ICAPRG301A Apply introductory programming techniques Functions Sometimes called methods or procedures Small bits of code that can be named and used as a single command Basic building blocks of programming In a well constructed program everything is inside a function In Python is defined by the command def