Introduction to Python

Slides:



Advertisements
Similar presentations
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Advertisements

© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
The Web Warrior Guide to Web Design Technologies
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
CMT Programming Software Applications
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?
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
JavaScript, Third Edition
Introduction to C Programming
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Introduction to Python
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Chapter 2: Java Fundamentals
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Introduction to Computer Programming
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
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.
A Python Tour: Just a Brief Introduction "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie.
Python 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Introduction to Programming
Fundamentals of Programming I Overview of Programming
C++ First Steps.
A Python Tour: Just a Brief Introduction
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Python Variable Types.
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
CSC201: Computer Programming
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Python
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Pamela Moore & Zenia Bahorski
Lesson 1 An Introduction
Java programming lecture one
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Introduction to Programming
PHP Introduction.
Introduction to the C Language
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Variables ICS2O.
Topics Introduction Hardware and Software How Computers Store Data
Python Primer 1: Types and Operators
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
PHP an introduction.
Computer Programming-1 CSC 111
Hardware is… Software is…
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Python CHAPTER ONE Introduction to Python

Python is a cross platform object-oriented programming language created by Guido van Rossum in 1991 runs on all major hardware platforms and operating systems, including Windows, Linux/UNIX, and Macintosh can also be used in procedural and functional styles currently has three implementations, known as CPython, Jython, and Iron- Python Cpython is the most widely used implementation

Python in the job market is the most popular programming language for 2017

Key features of python Python is easy to learn. It has easier to read syntax It uses white space for indentation Python is free has a large number of libraries included Can be integrated with other languages (mysql) Python is an interpreted language good for web development (also networking, gaming) provides for efficient memory management (garbage collection) supports exception handling

Installing python – Depends on OS Versions compatible with the textbook are Python 3.4 and PyQt4 Do not download the versions on the Unisa software disk For Python 3.4 go to :  https://www.python.org/downloads/release/python-340/ For PyQt4 got to :  https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/ Can watch video here : https://www.youtube.com/watch?v=O_xBNq833bM

Interacting with python Can work with Python using: Command Line Mode select Start > All Programs > Python 3.** IIDLE IDE select Start > All Programs > Python 3.** > IDLE

Interacting with python In Command Line mode you type Python instructions one line at a time and a history of the commands given is maintained. You can use the up and down arrows, as well as the Home,End, Page Up, and Page Down keys, to scroll through the commands used previously. Since whatever you type in command line mode is not saved, it is better to save code in a file and then execute it.

Interacting with python IDLE (Integrated Development Environment) IDLE combines an interactive interpreter with code editing, debugging tools, and several specialized browsers/viewers built into it. provides automatic indentation and colors to the code based on Python syntax types, making your program more readable. Also, you can navigate to the previously given commands that are in the buffer using the mouse, arrow keys, or Page Up and Page Down keys.

Data types in python Summary The operations that are applicable on an object depend on its data type

Data types in python Summary of data types Integers: Integers are 32 bits long ( –2,147,483,648 to 2,147,483,647). Long Integers: It has unlimited precision, subject to the memory limitations of the computer. Floating Point Numbers: Floating-point numbers are also known as double- precision numbers and use 64 bits. Boolean: It can hold only one of two possible values: True or False.

Data types in python Summary of data types Complex Number: A complex number has a real and an imaginary component, both represented by float types in Python. An imaginary number is a multiple of the square root of minus one, and is denoted by j. For instance, 2+3j is a complex number, where 3 is the imaginary component and is equal to 3 × √−1. Strings: Sequences of Unicode characters. Lists: Ordered sequences of values. Tuples: Ordered, immutable sequences of values. Sets: Unordered collections of values. Dictionaries: Unordered collections of key-value pairs.

Basic elements of a python program Literals, variables and keywords Every program consists of certain basic elements, a collection of literals, variables, and keywords.

Basic elements of a python program Literals Literal - a number or string that does not change

Basic elements of a python program Variables Variable - used for storing data in a program. To set a variable, you choose a name for your variable, and then use the equals sign followed by the data that it stores. Variables can be letters, numbers, or words Num1 = 15 literal variable

Basic elements of a python program Keywords Keywords - are identifiers that Python reserves for special use. Keywords contain lowercase letters only. You cannot use keywords as regular identifiers

Basic elements of a python program Comments Comments are the lines that are for documentation purposes and are ignored by the interpreter. The comments inform the reader what the program is all about. A comment begins by a hash sign (#). All characters after the # and up to the physical line end are part of the comment. For Example. # This program computes area of rectangle a=b+c # values of b and c are added and stored in a

Basic elements of a python program Continuation lines A physical line is a line that you see in a program. A logical line is a single statement in Python terms. In Python, the end of a physical line marks the end of most statements, unlike in other languages, where usually a semicolon (;) is used to mark the end of statements. When a statement is too long to fit on a single line, you can join two adjacent physical lines into a logical line by ensuring that the first physical line has no comment and ends with a backslash (\). Besides this, Python also joins adjacent lines into one logical line if an open parenthesis ( ( ), bracket ( [ ), or brace ( { ) is not closed. The lines after the first one in a logical line are known as continuation lines. The indentation is not applied to continuation lines but only to the first physical line of each logical line.

Basic elements of a python program Printing For printing messages and results of computations, the print() function is used with the following syntax: print(“message”,variable list) where message is the text string enclosed either in single or double quotes The variable list may be one or more variables containing the result of computation

Basic elements of a python program Printing – Concatenation – Joining 2 strings Using + sign print('Hello World!'+'It might rain today') output - Hello World!It might rain today (Note no space between) Using , print('Hello World!', 'It might rain today') output - Hello World! It might rain today (space between)

Basic elements of a python program Printing – Using end=‘ ’ end=‘ ’ suppresses printing on a new line It adds a space rather print on a new line print(“I love python,”, end=‘ ’) print(‘the language, not the snake’) Output - I love python, the language, not the snake

Basic elements of a python program Printing – Using (\) The \ operator adds a space rather print on a new line print('Hello World! \ It might rain today. \ Tomorrow is Sunday.') Output - Hello World! It might rain today. Tomorrow is Sunday.

Basic elements of a python program Printing – Using format codes - (%) used for substituting values in the variables at the desired place in the message

Notes