Class 2.

Slides:



Advertisements
Similar presentations
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Computer Science 101 Introduction to Programming.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
Python Programming Fundamentals
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Computer Science 101 Introduction to Programming.
UNIT - 1Topic - 3. Computer software is a program that tells a computer what to do. Computer software, or just software, is any set of machine-readable.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Variables and Expressions CMSC 201 Chang (rev )
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
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.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Variables  A piece of memory set aside to store data  When declared, the memory is given a name  by using the name, we can access the data that sits.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CMSC201 Computer Science I for Majors Lecture 03 – Variables
Thinking about programming
Agenda Introduction Computer Programs Python Variables Assignment
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
Topics Designing a Program Input, Processing, and Output
Chapter 1: Introduction to computers and C++ Programming
Topic: Python’s building blocks -> Statements
Chapter 2 - Introduction to C Programming
Topic: Python’s building blocks -> Variables, Values, and Types
Objectives Identify the built-in data types in C++
Presented By S.Yamuna AP/IT
Variables, Expressions, and IO
Chapter 2 - Introduction to C Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Topics Introduction Hardware and Software How Computers Store Data
Chapter 2 - Introduction to C Programming
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
CISC101 Reminders Labs start this week. Meet your TA! Get help with:
Topics Designing a Program Input, Processing, and Output
Chapter 2 - Introduction to C Programming
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
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.
Introduction to C Programming
Getting Started With Coding
Presentation transcript:

Class 2

The Universal Machine What is a computer program? A detailed, step-by-step set of instructions telling a computer what to do. If we change the program, the computer performs a different set of actions or a different task. The machine stays the same, but the program changes! Python Programming, 3/e

Hardware Basics Python Programming, 3/e

Hardware Basics Fetch-Execute Cycle First instruction retrieved from memory Decode the instruction to see what it represents Appropriate action carried out. Next instruction fetched, decoded, and executed. Lather, rinse, repeat! Python Programming, 3/e

Programming Languages High-level language c = a + b This needs to be translated into machine language that the computer can execute. Compilers convert programs written in a high-level language into the machine language of some computer. Python Programming, 3/e

Programming Languages Interpreters simulate a computer that understands a high-level language. The source program is not translated into machine language all at once. An interpreter analyzes and executes the source code instruction by instruction. Python Programming, 3/e

Review what we saw in lab 1 # This is a comment 2 an integer literal 3.14159 a floating point literal "Syracuse" a string literal

The Python shell prompt In the Python shell >>> The Python shell prompt >>> We type commands here and press the enter key Some statements show results >>> 2+3 5 Some statements do something without producing output. >>> length = 5

Variables Can store values – ints, floats, strings,... Naming rules for identifiers: UPPER case and lower case are different can begin with _underscore or letter followed by a sequence of letters, digits, or underscores Python keywords can't be variable names (p32)

identifiers Legal names: sk8er given_name houseNumber version3 Illegal names: 4kLift month/day day of week "variable" Legal but bad names: O o l

expressions: fragments of code that produce or calculate new data values not and expression: literals age = 15 variables 3+5 "Falk " + "100"

Assignment statement <variable> = <expr> Compute the expression on the right side. Put the result in the variable on the left side. examples: nonexamples: fish = "tuna" "weight" = 20 norm = x*x + y*y 100-37 = change

Operations On numbers. (ints, floats) () ** (exponentiation) * / + - On ints (discuss later) // % On strings +

the Python Shell Interprets commands as we go. Commands go at shell prompts: >>> >>> 2**5 32

the Python Shell Anything in a line after # is a comment, ignored by the computer >>> #Here is a comment >>> 8+45 # Add two numbers 53 >>> 1 + 2 # + 3 3 Why not 6?

the Python Shell remembers values till they are replaced till the shell is “restarted” like a long calculator tape