The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic.

Slides:



Advertisements
Similar presentations
Python Syntax. Basic Python syntax Lists Dictionaries Looping Conditional statements.
Advertisements

Python Mini-Course University of Oklahoma Department of Psychology Lesson 28 Classes and Methods 6/17/09 Python Mini-Course: Lesson 28 1.
Statement-Level Control Structures
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
Python: a modern hybrid A language for scripting and prototyping Balance between extensibility and powerful built-in data structures genealogy: –Setl (NYU,
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Introduction to Python
Chapter 2 Writing Simple Programs
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
Python Control of Flow.
Python.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
1 Python Control of Flow and Defining Classes LING 5200 Computational Corpus Linguistics Martha Palmer.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
The Python Language Petr Přikryl Part I Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic.
CS1022 Computer Programming & Principles Lecture 1.2 A brief introduction to Python.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
H3D API Training  Part 3.1: Python – Quick overview.
By: Chris Harvey Python Classes. Namespaces A mapping from names to objects Different namespaces have different mappings Namespaces have varying lifetimes.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
If statements while loop for loop
Hey, Ferb, I know what we’re gonna do today! Aims: Use formatted printing. Use the “while” loop. Understand functions. Objectives: All: Understand and.
Simple Functions and Names Sec 9-4 Web Design. Objectives The student will: Know how to create a simple function in Python. Know how to call a function.
Getting Started with Python: Constructs and Pitfalls Sean Deitz Advanced Programming Seminar September 13, 2013.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Ch. 10 For Statement Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
An Introduction. What is Python? Interpreted language Created by Guido Van Rossum – early 90s Named after Monty Python
Python I Some material adapted from Upenn cmpe391 slides and other sources.
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
Python 101 Dr. Bernard Chen University of Central Arkansas PyArkansas.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
Jim Havrilla. Invoking Python Just type “python –m script.py [arg]” or “python –c command [arg]” To exit, quit() or Control-D is used To just use the.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
11. EXCEPTION HANDLING Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
Python Let’s get started!.
1.3 Analysis And Synthesis OF LP Language Processor = Analysis of Source Program + Synthesis of Target Program. 1.
Chapter 10 Loops: while and for CSC1310 Fall 2009.
Python Basics  Functions  Loops  Recursion. Built-in functions >>> type (32) >>> int(‘32’) 32  From math >>>import math >>> degrees = 45 >>> radians.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
Introduction to Computing Using Python Repetition: the for loop  Execution control structures  for loop – iterating over a sequence  range() function.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Introduction to Programming Oliver Hawkins. BACKGROUND TO PROGRAMMING LANGUAGES Introduction to Programming.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
Python Flow of Control CS 4320, SPRING Iteration The ‘for’ loop is good for stepping through lists The code below will print each element in the.
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
Lecture III Syntax ● Statements ● Output ● Variables ● Conditions ● Loops ● List Comprehension ● Function Calls ● Modules.
Chapter 2 Writing Simple Programs
Information and Computer Sciences University of Hawaii, Manoa
CS1022 Computer Programming & Principles
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Python Let’s get started!.
loops for loops iterate over a given sequence.
Statement atoms The 'atomic' components of a statement are: delimiters (indents, semicolons, etc.); keywords (built into the language); identifiers (names.
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during.
Python Primer 2: Functions and Control Flow
Topics Introduction to File Input and Output
Introduction to Python
CISC101 Reminders Quiz 1 grading underway Assn 1 due Today, 9pm.
Python I Some material adapted from Upenn cmpe391 slides and other sources.
CISC101 Reminders All assignments are now posted.
Module 2 - Part 1 Variables, Assignment, and Data Types
COMPUTER PROGRAMMING SKILLS
Python Reserved Words Poster
Presentation transcript:

The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic

June 2004, Socrates IP... syntax, semantics and examples

June 2004, Socrates IP The Python Language 3 Objects are garbage collected l Automatic memory management. l Reference counting. l Cyclic references. l To decrease the reference counter: u rebind to None u use del

June 2004, Socrates IP The Python Language 4... example

June 2004, Socrates IP The Python Language 5... removing the name

June 2004, Socrates IP The Python Language 6 Simple statements l... do not look as function calls: u assignment u print u del u pass (def myFunction: pass) u return u raise u try / except u assert

June 2004, Socrates IP The Python Language 7 Built-in functions l Predefined functions, always available: u id() u type() u str() u repr()

June 2004, Socrates IP The Python Language 8 Block, indentation, readability l Indentation defines what is inside the block. l The more indent steps, the deeper the block is. l “Life is better without braces” (Eckel) l More strict formatting rules – more readable source. l Even those disgusted by missing braces do like it at the end (at least, no problem – Raymond).

June 2004, Socrates IP The Python Language 9 Programming constructions l if – elif – else l while l for

June 2004, Socrates IP The Python Language 10 if – elif – else

June 2004, Socrates IP The Python Language 11 elif is good... l Replacement for the switch statement:

June 2004, Socrates IP The Python Language 12 elif is not necessary

June 2004, Socrates IP The Python Language 13 while, the general loop

June 2004, Socrates IP The Python Language 14 for – iteration through all items l Not a counted loop. l No direct indexing. l More modern, iterators.

June 2004, Socrates IP The Python Language 15 for, simulation of the counted loop

June 2004, Socrates IP The Python Language 16 xrange() with step

June 2004, Socrates IP The Python Language 17 Functions l They use return: l Arguments are passed by references, any type:

June 2004, Socrates IP The Python Language 18 Generators l They use yield; iterators:

June 2004, Socrates IP The Python Language 19 Generators and their iterators

June 2004, Socrates IP The Python Language iterator

June 2004, Socrates IP The Python Language 21 The iteration inside while

June 2004, Socrates IP The End of Part II

June 2004, Socrates IP The Python Language capturing the exception

June 2004, Socrates IP The Python Language continue