Python Programming Chapter 1: The way of the program Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

Python Programming Chapter 5: Fruitful Functions Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Programming Types of Testing.
 Introduction to Programming History of programming.
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.
Debugging Introduction to Computing Science and Programming I.
Python Programming Chapter 12: Classes and Objects Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2010/2011.
How to Create a Java program CS115 Fall George Koutsogiannakis.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Python Programming Chapter 2: Variables, expressions, and statements Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
PRE-PROGRAMMING PHASE
Compiling and Linking. Compiling is quite the same as creating an executable file! Instead, creating an executable is a multistage process divided into.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
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.
ITP © Ron Poet Lecture 1 1 IT Programming Introduction.
Computer Science 101 Introduction to Programming.
Introduction to Computer Programming
Thanks to: Dr. John S. Mallozzi Department of Computer Science 1. Introduction 2. Overview of programming in Python.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to High-Level Language Programming
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Programming for Linguists An Introduction to Python.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CMPT 120 How computers run programs Summer 2012 Instructor: Hassan Khosravi.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
Introduction to Python
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Computing Science 1P Lecture 21: Friday 20 th April Simon Gay Department of Computing Science University of Glasgow 2006/07.
General Programming Introduction to Computing Science and Programming I.
Invitation to Computer Science, Java Version, Second Edition.
PhD, Senior Lecturer, Baimuratov Olimzhon A LGORITHMS & P ROGRAMMING (P YTHON ) Lecture 1 From SDU:
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Introduction to Programming Peggy Batchelor.
Programming in Python Part I Dr. Fatma Cemile Serçe Atılım University
Computer Science 101 Introduction to Programming.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
Python Programming Chapter 6: Iteration Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Python From the book “Think Python”
Linux Operations and Administration
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
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.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Programming Objectives What is a programming language? Difference between source code and machine code What is python? – Where to get it from – How to.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Introduction to Computing Science and Programming I
CMPT 120 Topic: Python’s building blocks -> More Statements
Topic: Programming Languages and their Evolution + Intro to Scratch
Teaching Computing to GCSE
Programming.
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
1.3.7 High- and low-level languages and their translators
Presentation transcript:

Python Programming Chapter 1: The way of the program Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012

2 The Python Programming Language  Python is an example of a high-level language; other high-level languages you have heard of are C, C++, and Java.  As you might infer from the name “high-level language,” there are also low-level languages, sometimes referred to as “machine languages” or “assembly languages.”  Loosely speaking, computers can only execute programs written in low-level languages. Thus, programs written in a high-level language have to be processed before they can run.  This extra processing takes some time, which is a small disadvantage of high- level languages. But the advantages are enormous. First, it is much easier to program in a high-level language. Programs written in a high- level language take less time to write, they are shorter and easier to read, and they are more likely to be correct. Second, high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.

3 The Python Programming Language (Cont....)  Due to these advantages, almost all programs are written in high-level languages. Low-level languages are used only for a few specialized applications.  Two kinds of programs process high-level languages into low-level languages: interpreters and compilers.  An interpreter reads a high-level program and executes it, meaning that it does what the program says. It processes the program a little at a time, alternately reading lines and performing computations.  A compiler reads the program and translates it completely before the program starts running. In this case, the high-level program is called the source code, and the translated program is called the object code or the executable. Once a program is compiled, you can execute it repeatedly without further translation.

4 The Python Programming Language (Cont....)  Python is considered an interpreted language because Python programs are executed by an interpreter.  There are two ways to use the interpreter: command-line mode and script mode.  In command-line mode, you type Python programs and the interpreter prints the result: >>> print  The first line starts with >>>, which is the prompt the interpreter uses to indicate that it is ready. We typed print 1 + 1, and the interpreter replied 2.  Alternatively, you can write a program in a file and use the interpreter to execute the contents of the file. Such a file is called a script. For example, we used a text editor to create a file named latoya.py with the following contents: print  By convention, files that contain Python programs have names that end with.py.

5 What is Debugging?  Programming is a complex process, and because it is done by human beings, it often leads to errors.  Programming errors are called bugs and the process of tracking them down and correcting them is called debugging.  Three kinds of errors can occur in a program and It is useful to distinguish between them in order to track them down more quickly. Syntax Errors. Runtime Errors. Semantic Errors.

6 Syntax Errors  Python can only execute a program if the program is syntactically correct; otherwise, the process fails and returns an error message. Syntax refers to the structure of a program and the rules about that structure.  If there is a single syntax error anywhere in your program, Python will print an error message and quit, and you will not be able to run your program.

7 Runtime Errors  The second type of error is a runtime error, so called because the error does not appear until you run the program.  These errors are also called exceptions because they usually indicate that something exceptional (and bad) has happened.

8 Semantic Errors  The third type of error is the semantic error.  If there is a semantic error in your program, it will run successfully, in the sense that the computer will not generate any error messages, but it will not do the right thing. It will do something else.  Specifically, it will do what you told it to do.  The problem is that the program you wrote is not the program you wanted to write.  The meaning of the program (its semantics) is wrong.  Identifying semantic errors can be tricky because it requires you to work backward by looking at the output of the program and trying to figure out what it is doing.

9 Experimental Debugging  Debugging is one of the most important skills that you will acquire.  Although it can be frustrating, debugging is one of the most intellectually rich, challenging, and interesting parts of programming.  Debugging is like an experimental science. Once you have an idea what is going wrong, you modify your program and try again. If your hypothesis was correct, then you can predict the result of the modification, and you take a step closer to a working program. If your hypothesis was wrong, you have to come up with a new one.  For some people, programming and debugging are the same thing. That is, programming is the process of gradually debugging a program until it does what you want.  The idea is that you should start with a program that does something and make small modifications, debugging them as you go, so that you always have a working program.

10 Formal and Natural Languages  Natural languages are the languages that people speak, such as English, Spanish, and French.  They were not designed by people (although people try to impose some order on them); they evolved naturally.  Formal languages are languages that are designed by people for specific applications.  For example, the notation that mathematicians use is a formal language that is particularly good at denoting relationships among numbers and symbols. Chemists use a formal language to represent the chemical structure of molecules. And most importantly: Programming languages are formal languages that have been designed to express computations.

11 The First Program  Traditionally, the first program written in a new language is called “Hello, World!” because all it does is display the words, “Hello, World!”.  In Python, it looks like this: print "Hello, World! "  This is an example of a print statement, which doesn't actually print anything on paper. It displays a value on the screen. In this case, the result is the words: Hello, World!  The quotation marks in the program mark the beginning and end of the value; they don't appear in the result.  Some people judge the quality of a programming language by the simplicity of the “Hello, World!” program. By this standard, Python does about as well as possible.