Level 3 Computing Year 2 Lecturer: Phil Smith

Similar documents
Python - Variable Types. John R. Woodward

ENGR 101 Engineering Design Workshop

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

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Python Intro GIS Week 1. Jake K. Carr

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Python Input, output and variables

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

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

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

PYTHON. Varun Jain & Senior Software Engineer. Pratap, Mysore Narasimha Raju & TEST AUTOMATION ARCHITECT. CenturyLink Technologies India PVT LTD

Unit 6 - Software Design and Development LESSON 4 DATA TYPES

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Algorithms and Programming I. Lecture#12 Spring 2015

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Lesson 4: Type Conversion, Mutability, Sequence Indexing. Fundamentals of Text Processing for Linguists Na-Rae Han

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

[301] JSON. Tyler Caraza-Harter

CS 102 Lab 3 Fall 2012

BTE2313. Chapter 2: Introduction to C++ Programming

COMP519 Web Programming Lecture 11: JavaScript (Part 2) Handouts

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

CMSC201 Computer Science I for Majors

CS242 COMPUTER PROGRAMMING

Variable and Data Type I

Chapter 2 Basic Elements of C++

User Defined Functions

Python Review IPRE

1/11/2010 Topic 2: Introduction to Programming 1 1

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

Language Reference Manual

Variable and Data Type I

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Exercise: Inventing Language

Topic 2: Introduction to Programming

Python I. Some material adapted from Upenn cmpe391 slides and other sources

COMP1730/COMP6730 Programming for Scientists. Strings

Week 3 Lecture 2. Types Constants and Variables

ARG! Language Reference Manual

Notes on Chapter 1 Variables and String

CSc Introduction to Computing

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

Introduction to Java & Fundamental Data Types

MICROPROCESSOR SYSTEMS INTRODUCTION TO PYTHON

Introduction to Python (All the Basic Stuff)

Expressions and Variables

CS 141, Lecture 3. Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered. <-- fine <-- fine <-- broken

QUark Language Reference Manual

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

Python: common syntax

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

ENGR/CS 101 CS Session Lecture 12

Python Review IPRE

CSCA08 Winter 2018 Week 2: Variables & Functions. Marzieh Ahmadzadeh, Brian Harrington University of Toronto Scarborough

Variables, expressions and statements

ENGR 102 Engineering Lab I - Computation

S206E Lecture 19, 5/24/2016, Python an overview

Python memento TI-Smart Grids

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

JAC444 - Lecture 1. Introduction to Java Programming Language Segment 4. Jordan Anastasiade Java Programming Language Course

Introduction to Python

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

C++ Programming: From Problem Analysis to Program Design, Third Edition

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Types, lists & functions

CS201 Some Important Definitions

CSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016

Course Outline - COMP150. Lectures and Labs

Introduction To C#.NET

Worksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2

C programming Lecture 2. Marina Krstic Marinkovic School of Mathematics Trinity College Dublin

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

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

Python as a First Programming Language Justin Stevens Giselle Serate Davidson Academy of Nevada. March 6th, 2016

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions.

CS1 Lecture 3 Jan. 22, 2018

PYTHON. Values and Variables

Lecture 5. Daily Puzzle. Variables and Identifiers. Place 10 lumps of sugar in 3 cups so there would be an odd number of lumps in every cup.

Iterators & Generators

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

Python in 10 (50) minutes

Chapter 2: Introduction to C++

Full file at

Fundamentals of Python: First Programs. Chapter 4: Strings (Indexing, Slicing, and Methods)

Programming I. Course 9 Introduction to programming

Chapter 2 Working with Data Types and Operators

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Introduction to Problem Solving and Programming in Python.

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Python Class-Lesson1 Instructor: Yao

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Python Programming Challenges

Working with Strings. Husni. "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc.

The Practice of Computing Using PYTHON. Chapter 4. Working with Strings. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Transcription:

Level 3 Computing Year 2 Lecturer: Phil Smith

Previously We learnt what a computer program does. What a procedural program does. What a procedure is. We had a first look at IDLE.

Now Learning Outcomes 1. Understand the features of procedural programming. Procedures we need to add a bit more on to the definition from last lesson. Functions and pre defined functions. Variables and variable scope. Parameters. Modularity. Programming libraries. Control structures (iteration). Conditional commands (selection).

LO1 Features We start by learning about variables. 1. Principles 2. Design 3. Syntax 4. Implementation 5. Scope

Variables In order to process input the information must first be stored in memory. For this all program languages use variables.

Variables Input variables In memory (RAM) Could be the same Output variables

What is a variable? Variables In Python we define a variable like this myvariable Instance variable names should be all lower case. Words in an instance variable name should be separated by an underscore It should have a meaningful name and be as short as possible. It should have a datatype.

Variables Watch out for this little gotcha Python is case sensitive?? So myvar is a different variable to myvar This will catch at least one of you out. (It has me)

Variable Data types All variables have a type e.g. String, Integer, Decimal, Float etc These data types determine the type of data that can be placed into the variable and also defines the amount (size) of memory needed to store the data. Python provides a wide range of data types. https://docs.python.org/2/library/datatypes.html

Variable Data types All values have a data type (a catogory of values) and every value belongs to a single data type. In Python, data types are inferred from the type of data assigned to the variable. E.g myvar = 42 is a string data type Myvar = 42 is an int data type so "42" (str) is not the same as 42 (int)

Variable String Data type Strings in Python are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from 1 at the end.

Variable Data types Activity numbers and strings Start IDLE on your PC

Variable List Data types Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type. Example list = [1, 2, 3, 4, 5, 6, a, b, c ] or Small_list = [123, Phil ]

Activity on lists Variable Data types Start IDLE on your PC

Variable assignment If you type 22 + 10 in idle the result displayed will be 32. This is an example of a code statement. If you type answer = 22 + 10 in IDLE then 32 is stored inside the variable answer, its data type will be int. When there is an assignment in the statement then this is called an expression. In IDLE you can then enter the variable name and the result is displayed.

Variable assignment So how can we enter a number of statements/expressions to be executed all together rather than one statement at a time (as in IDLE) Let s explore this option and also write a code sequence to show input, process and output.

Start IDLE on your PC Activity Then follow my lead.

Summary What have we learned today?