Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
The Web Warrior Guide to Web Design Technologies
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Introduction to Perl Learning Objectives: 1. To introduce the features provided by Perl 2. To learn the basic Syntax & simple Input/Output control in Perl.
 2002 Prentice Hall. All rights reserved. 1 Intro: Java/Python Differences JavaPython Compiled: javac MyClass.java java MyClass Interpreted: python MyProgram.py.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
Guide To UNIX Using Linux Third Edition
CSC 9010: Natural Language Processing
Computer Science 210 Computer Organization Introduction to C.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Input, Output, and Processing
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Python – May 11 Briefing Course overview Introduction to the language Lab.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
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.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
PHP using MySQL Database for Web Development (part II)
CGS 3066: Web Programming and Design Spring 2017
Introduction to GIS PythonScript CGIS-NURIntroduction to ArcGIS II.
A Python Tour: Just a Brief Introduction
Topics Designing a Program Input, Processing, and Output
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Chapter 6 JavaScript: Introduction to Scripting
Computer Science 210 Computer Organization
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)
Topics Introduction Hardware and Software How Computers Store Data
Getting Started with C.
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Programming Language Concepts (CIS 635)
JavaScript.
Computer Science 210 Computer Organization
JavaScript an introduction.
Introduction to Python
Chapter 2 - Introduction to C Programming
Chapter 11 Introduction to Programming in C
Chapter 2 - Introduction to C Programming
Chapter 11 Introduction to Programming in C
PHP.
Introduction to C Topics Compilation Using the gcc Compiler
Creating your first C program
Chapter 2 - Introduction to C Programming
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Chapter 11 Introduction to Programming in C
Intro to PHP.
Topics Designing a Program Input, Processing, and Output
Introduction to C Topics Compilation Using the gcc Compiler
Topics Designing a Program Input, Processing, and Output
JavaScript CS 4640 Programming Languages for Web Applications
Chapter 2 - Introduction to C Programming
12th Computer Science – Unit 5
PHP an introduction.
Introduction to Perl Learning Objectives:
Introduction to C Programming
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Structural Program Development: If, If-Else
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its code is concise but at the same highly readable (pythonic). It is dynamically typed: a variables does not need a predefined type. Other than the basic types, It also has built-in collection types: lists tuples dictionaries (maps) sets It can be linked to C/C++/Java codes that handle time-critical jobs more efficiently. It has a large collection of standard and special-purpose libraries.

Other Features It uses indentations (not braces or keywords) to define blocks. It has three frequently used sequence types: strings: ‘xyz’, immutable, for characters. lists: […], mutable, for any objects. tuples: (…), immutable, for any objects. It supports multiple paradigms (obj-oriented, functional, procedural). It has powerful subscripting/slicing methods. It is one of the most popular scripting languages (Perl, PHP, Tcl, JavaScript and Unix shell scripts). It has found numerous applications, especially in string/text manipulation, file/directory management, and web design. It is open-source and is available in all major systems.

Comparison C/C++/Java Statically typed. A variable’s type must be declared before it can be used. Methods use type signatures to enforce contracts. Python Dynamically typed. A variables comes into existence when first assigned a value. A variable can refer to an object of any type. Most types are treated the same way. Drawback: type errors are caught at runtime only.

Python Versions Python 2.x The latest stable release: 2.7 It implements certain new features of 3.x and is fully backwards compatible. Python 3.x The latest release: 3.6.2 Strings use Unicode, not ASCII. It contains many new features and are cleaner. It has compatibility issues with the legacy codes written with 2.x versions.

Run Python interactively (command-line mode) Python 2.5 (r25:51908, May 25 2007, 16:14:04) [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> 2+3 5 “>>>” is the Python prompt sign. “CTRL-D” to exit Python.

Run Python code in a file % python example.py --- Add this line at the top of the file: #!/usr/bin/python --- Make the file executable. We will run Python in the IDLE environment (to be discussed in lab sessions).

A Code Sample # This is a Python code sample. a = 22 b = a + 33 c = 3.1415 d = "YSU" if a == 44 or d == "YSU": a = a +1 d = d + "Football" print (a) print (b) print (c) print (d)

Explanations Indentation has special meanings: It indicates a block structure. The first assignment to a variable creates it. A variable’s type does not need to be declared. Python figures out a variable type in the context. “=“ is assignment operator, and “==“ is comparison operator. “+”, “-”, “*”, “/”, “%” are arithmetic operators. “+” means concatenation for strings. “%” indicates formatting for a string (similar to “printf” in C). Logical operators are words (and, or, not). Simple I/O: num = input ('Enter a number: ') print (*objects, sep=' ', end='\n', file=sys.stdout, flush=False)

Basic Types Integers (default for numbers) x = 34 Floating points Strings s1 = “YSU” s2 = ‘YSU’

Whitespace and Indentation Whitespace has special meanings in Python. Within an expression or a statement, whitespaces are ignored. Leading whitespace of a line defines indentation. Consistent indentations define blocks. The first line with less indentation is outside of the block. The first line with more indentation starts a nested block. A colon often appears at the start of a new block (function and class). A newline ends a line of code. Continuation of a long line to the next line is indicated by putting the backslash character (\) at the end of a line.

Assignments In Python, binding a variable means setting a name to hold a reference to an object. Assignment creates references, not copies (as in Java) A variable is created the first time it appears on the left side of an assignment expression: An object is deleted (by garbage collector) once it becomes unreachable. Names in Python do not have an intrinsic type. Objects have types. Python determines the type of a reference automatically based on what data is assigned to it.