Introduction to Computers and Programming 01204111 – Computer Programming.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
The Analytical Engine Module 6 Program Translation.
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Program Flow Charting How to tackle the beginning stage a program design.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Course: Introduction to Computers
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Thanks to: Dr. John S. Mallozzi Department of Computer Science 1. Introduction 2. Overview of programming in Python.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introduction COMP104: Fundamentals and Methodology.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Topics Introduction Hardware and Software How Computers Store Data
High-level Languages.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
CSC141 Introduction to Computer Programming
Programming 1 1. Introduction to object oriented programming and problem-solving.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
Computer system overview1 The Effects of Computers Pervasive in all professions How have computers affected my life? How have computers affected my life?
Course Overview. What are Computers? From Outside –CPU box, Monitor, Keyboard, mouse and Printers From inside –ICs, Chipsets, Hard Disks, PCB cards, Drives,
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Python From the book “Think Python”
Visual C++ Programming: Concepts and Projects
Introduction to Computer and Programing Thanachat Thanomkulabut.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
Chapter 0 Overview. Why you are here? Where will you go? What is this course for?
1 st Semester Introduction to Computer and Programming Computer Engineering Department Kasetsart University, Bangkok, THAILAND.
Introduction to Computer and Programing Thanachat Thanomkulabut.
2 nd Semester Module1 Introduction to Computer and Programming อภิรักษ์ จันทร์สร้าง Aphirak Jansang
Computers and Programming ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Introduction to Computer and Programing Thanachat Thanomkulabut.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Evolution and History of Programming Languages
Basic Concepts: computer, program, programming …
Java Programming: From the Ground Up
Development Environment
Lecture 1: Introduction to JAVA
Microprocessor and Assembly Language
Programming COMP104: Fundamentals and Methodology Introduction.
TRANSLATORS AND IDEs Key Revision Points.
Programming for Business Computing Introduction
Presentation transcript:

Introduction to Computers and Programming – Computer Programming

2 What is a computer? A computer is a machine that  Follows instructions (software) in memory  Reads input data  Stores and processes data  Produce outputs

3 Development Abacus Analytical Engine 1 Generation ( ): Vacuum Tubes 2 Generation ( ): Transisters 3 Generation ( ): Integrated Circuits 4 Generation (1971-Present): Microprocessors, VLSI/ULSI

4 Types of computers Desktop computers Notebook computers Mobile computers (Personal Digital Assistants, PDA) Mainframes Super computers Microcomputers

5 Hardware Input devices Output devices Central Processing Unit (CPU) Main memory Storage

6 Computer Programming To program a computer is to write instructions so that the computer can complete the required task. These instructions must be specific and unambiguous.  To do so, you have to think carefully and describe your idea into instructions in the language that the machine can understand.

7 Basic Steps Problem analysis Program design Implementation Testing

8 Programming languages  Low-level languages. e.g., machine languages, assembly language  High-level language. e.g., C, Pascal, Java, C#, Python

9 Low-level languages Instructions depend on the specific architecture of the machines  E.g., x86, ARM, AVR architectures Each instruction correspond to specific cycle of execution A program written for a specific architecture cannot be executed in another architecture.

10 Low-level languages Machine languages  Ready to be executed  Usually written as binary or hexadecimal numbers Assembly language  Encoded machine languages  Each instruction corresponds to one machine instruction. SUBR3, #2, R B 19 FC 98 E0 รหัสฐานสอง รหัสฐานสิบหก

11 High-level languages Read more naturally Are usually independent of the underlying architecture. -> More portable Each statement may correspond to many machine instructions SUM := A * 2 + ALPHA/3; PRINTLN(SUM); SUM := A * 2 + ALPHA/3; PRINTLN(SUM);

12 Example of high-level languages Procedural  Fortran  Cobol  Basic  C  Pascal Functional  Lisp Object-oriented  C++  Java  C#  VB Logic  Prolog

Program Execution A computer does not "understand" high-level languages. To execute program in these languages, you need either:  An interpreter  A compiler 13

14 Interpreters An interpreter reads each high-level language instruction and executes that instruction, one by one. อินเทอร์พรีเตอร์อินพุท เอาท์พุท prog.bas ซอร์สโค้ด

15 Compilers A compiler reads the whole program and translate it into machine readable instructions. คอมไพเลอร์อินพุท เอาท์พุท prog.c ซอร์สโค้ด prog.exe รหัสภาษาเครื่อง

16 Languages used in this course Python  An interpretative language  Can be used on many computing systems (e.g., on MS Windows, Unix, and even some mobile phones). C#  A compilation language  More restrictive syntax  Very good for developing GUI applications

17 Python Is a multi-paradigm programming language  Procedural  Functional  Object-oriented Is an interpretative language Easy to get started Very rich standard library

18 Installation Download Python 3.1 at  1.2/python msi 1.2/python msi After the installation, you can try calling the Python Shell from the Start Menu.

19 Thinking Corners Try to guess what the following program is doing. print("Welcome") g = input("Guess the number: ") guess = int(g) if guess == 5: print("You win!") else: print("You lose!") print("Game over!") print("Welcome") g = input("Guess the number: ") guess = int(g) if guess == 5: print("You win!") else: print("You lose!") print("Game over!") 1: 2: 3: 4: 5: 6: 7: 8: 1: 2: 3: 4: 5: 6: 7: 8:

20 Natural languages A program is not that different from human natural language Display "Welcome" Let g be input("Guess the number: ") Let guess be int(g) if guess equals 5: Display "You win!" else: Display "You lose!" Display "Game over!" Display "Welcome" Let g be input("Guess the number: ") Let guess be int(g) if guess equals 5: Display "You win!" else: Display "You lose!" Display "Game over!" 1: 2: 3: 4: 5: 6: 7: 8: 1: 2: 3: 4: 5: 6: 7: 8:

21 Interaction with Python A "prompt" that shows that the system is ready to take commands

22 Try this Try these commands (Don't type >>>) and observe the output >>> print(1) >>> print(3*8) >>> print("Hello") >>> input() >>> exit() >>> print(1) >>> print(3*8) >>> print("Hello") >>> input() >>> exit()

23 Combining instructions into programs We can combine many instructions into a single program for ease of usage later on.  Each instruction are executed in order from top to bottom.  We call this sequence of instructions "a program". You can use any editing software to create this program file, e.g., Notepad. Python programs's names end with.py,e.g., first.py

24 Traditional program development cycle Pythoninput output prog.py program Editor The development process gets much simplified with the use of IDE's. We shall talk about a particular IDE on the next few slides.

25 How to run your program You can double-click at the.py file. The Python interpreter will start to execute your program. Notes: After the program finishes, the window will be closed immediately.  By adding a command " input()", you can keep the window opened.

26 Wing IDE 101 In this course, we will develop programs in an Integrated Development Environment (IDE)  It has a build-in editor  Can execute programs inside the system  It comes with a debugging tool.

27 Turtle-style graphics We shall learn basic ideas of programming by telling and teaching turtles to draw. From the Python Shell we can start using the Turtle graphics system by typing from turtle import *

28 What can a turtle do? Moves forward/backward Turns left or right Takes a pen with it

29 Basic turtle control t = Turtle() – Create a turtle, call it t t.forward(d) - tell t to walk d steps t.backward(d) - tell t to walk backwards d for steps t.right(a) - tell t to turn right for a degree t.left(a) - tell t to turn left for a degree t.penup() – tell t to lift the pen up from the canvas t.pendown() - tell t to put the pen back to the canvas

Tell the turtle to draw a square In English: 30 Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree Walk for 100 steps Turn right 90 degree

Tell the turtle to draw a square In Python: 31 from turtle import * t = Turtle() t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) from turtle import * t = Turtle() t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100)

32 Teach the turtle You can define new commands using def from turtle import * t = Turtle() def square(): t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) square() from turtle import * t = Turtle() def square(): t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) square() Make sure the indentati on is aligned.

33 Repetitive instructions The instructions are very repetitive. High-level languages have ways to reduce this instruction repetition and duplication  To reduce program complexity and increase readability. from turtle import * t = Turtle() def square(): for x in range(4): t.forward(100) t.right(90) square() from turtle import * t = Turtle() def square(): for x in range(4): t.forward(100) t.right(90) square()

34 Thinking Corner Write a program that tells the turtle to draw a equilateral triangle whose sides are 200- step long, on the canvas.

35 Software required for the first half Python  thon msi Wing IDE 101  An integrated development environment for Python  exe