Zaczynamy Programować W Języku Python

Total Page:16

File Type:pdf, Size:1020Kb

Zaczynamy Programować W Języku Python ZACZYNAMY PROGRAMOWAĆ W JĘZYKU PYTHON AGNIESZKA BOROWIECKA Agenda • Rozmawiamy z komputerem • Słów kilka o Pythonie • Mój własny Python • Zaczynamy zabawę Rozmawiamy z komputerem Rozmawiamy z komputerem Języki naturalne i języki programowania • język naturalny • język maszynowy alfabet = zestaw symboli słownik = zbiór słów składnia = reguły określające sposób budowy zdania semantyka = reguły określające sens logiczny zdania • język programowania wysokiego poziomu kod źródłowy plik źródłowy Rozmawiamy z komputerem Kompilacja vs. interpretacja Poprawność programu: Od języka wysokiego poziomu do języka maszynowego • alfabetyczna • kompilacja • leksykalna • interpretacja • syntaktyczna • semantyczna Słów kilka o Pythonie Słów kilka o Pythonie Trochę historii W grudniu 1989 r. szukałem „hobbistycznego” projektu z dziedziny programowania, który pozwoliłby mi zająć czymś czas w ciągu tygodnia w okolicach Bożego Narodzenia. Moje biuro (...) miało być zamknięte, ale miałem komputer domowy i niewiele do roboty. Postanowiłem stworzyć interpreter dla nowego języka skryptowego, (...) który byłby atrakcyjny dla hakerów Unix / C. • Guido van Rossum (ur. 1956 Haarlem, Holandia) • nazwa – Latający Cyrk Monty Pythona • początki – lata 90. XX wieku • wersje: • do 1.2 – Centrum Matematyki i Informatyki (CWI) w Amsterdamie • do 1.6 – Corporation for National Research Initiatives (CNRI) w Reston w Wirginii • BeOpen.com – PythonLabs – 2.0 • Digital Creations – Python Software Foundation https://pl.wikipedia.org/wiki/Guido_van_Ro ssum#/media/Plik:Guido-portrait-2014.jpg Słów kilka o Pythonie Python – język interpretowany (skryptowy) • uruchamiamy zaraz po napisaniu • można uruchamiać na różnych komputerach/systemach • bezpłatny • do uruchomienia potrzebny interpreter • wolny – pamięć na program i interpreter • słabe wsparcie urządzeń mobilnych Słów kilka o Pythonie Dlaczego Python? • łatwy i intuicyjny język • otwarty (open source) • zrozumiały, jak język naturalny • odpowiedni do codziennych zadań • ... • szeroko wykorzystywany • liczne zastosowania praktyczne Słów kilka o Pythonie Kto korzysta z Pythona? • Google • Uber • NASA • Yahoo • YouTube • Nokia • Netflix • IBM • Facebook • ... • Spotify • Instagram • Pinterest Słów kilka o Pythonie Zastosowania Pythona • aplikacje internetowe: • wyszukiwarki • przechowywanie w chmurze (Dropbox) • media społecznościowe • aplikacje komputerowe • język skryptowy w aplikacjach np. GIMP, Inkscape, Blender, The Sims 4, Civilization IV • MicroPython – mikrokontrolery, Raspberry Pi Mój własny Python Mój własny Python Wersje i implementacje • Python 2 – aktualizacje zawierają tylko poprawki • Python 3 – aktualna i rozwijana • CPython (napisany w C), • Jython (napisany w Javie), • CLPython (napisany w Common Lisp), • IronPython (napisany w C# na platformę .NET) • PyPy (napisany w Rpythonie) • Cython – automatyczne tłumaczenie z języka Python na C Mój własny Python System operacyjny a Python • Linux – preinstalowany Python 3 (w terminalu python3) • Macintosh - Mac OS X 10.8 preinstalowany Python 2.7 • https://www.python.org/downloads Mój własny Python IDLE Integrated Development and Learning Environment • środowisko programistyczne • edytor • konsola (shell) • debugger Mój własny Python Mu Editor • https://codewith.mu • napisany w Pythonie Mój własny Python PyCharm • zintegrowane środowisko programistyczne • wolna wersja Community Edition • https://www.jetbrains.com/pycharm Mój własny Python Edytory online • ideone.com • repl.it • onlinegdb.com • https://repl.it/languages/python_turtle • https://trinket.io/turtle • https://skulpt.org Zaczynamy zabawę Zaczynamy zabawę A teraz czas zacząć programować... DZIĘKUJĘ ZA UWAGĘ Agnieszka Borowiecka .
Recommended publications
  • An Implementation of Python for Racket
    An Implementation of Python for Racket Pedro Palma Ramos António Menezes Leitão INESC-ID, Instituto Superior Técnico, INESC-ID, Instituto Superior Técnico, Universidade de Lisboa Universidade de Lisboa Rua Alves Redol 9 Rua Alves Redol 9 Lisboa, Portugal Lisboa, Portugal [email protected] [email protected] ABSTRACT Keywords Racket is a descendent of Scheme that is widely used as a Python; Racket; Language implementations; Compilers first language for teaching computer science. To this end, Racket provides DrRacket, a simple but pedagogic IDE. On the other hand, Python is becoming increasingly popular 1. INTRODUCTION in a variety of areas, most notably among novice program- The Racket programming language is a descendent of Scheme, mers. This paper presents an implementation of Python a language that is well-known for its use in introductory for Racket which allows programmers to use DrRacket with programming courses. Racket comes with DrRacket, a ped- Python code, as well as adding Python support for other Dr- agogic IDE [2], used in many schools around the world, as Racket based tools. Our implementation also allows Racket it provides a simple and straightforward interface aimed at programs to take advantage of Python libraries, thus signif- inexperienced programmers. Racket provides different lan- icantly enlarging the number of usable libraries in Racket. guage levels, each one supporting more advanced features, that are used in different phases of the courses, allowing Our proposed solution involves compiling Python code into students to benefit from a smoother learning curve. Fur- semantically equivalent Racket source code. For the run- thermore, Racket and DrRacket support the development of time implementation, we present two different strategies: additional programming languages [13].
    [Show full text]
  • A Python Implementation for Racket
    PyonR: A Python Implementation for Racket Pedro Alexandre Henriques Palma Ramos Thesis to obtain the Master of Science Degree in Information Systems and Computer Engineering Supervisor: António Paulo Teles de Menezes Correia Leitão Examination Committee Chairperson: Prof. Dr. José Manuel da Costa Alves Marques Supervisor: Prof. Dr. António Paulo Teles de Menezes Correia Leitão Member of the Committee: Prof. Dr. João Coelho Garcia October 2014 ii Agradecimentos Agradec¸o... Em primeiro lugar ao Prof. Antonio´ Leitao,˜ por me ter dado a oportunidade de participar no projecto Rosetta com esta tese de mestrado, por todos os sabios´ conselhos e pelos momentos de discussao˜ e elucidac¸ao˜ que se proporcionaram ao longo deste trabalho. Aos meus pais excepcionais e a` minha mana preferida, por me terem aturado e suportado ao longo destes quase 23 anos e sobretudo pelo incondicional apoio durante estes 5 anos de formac¸ao˜ superior. Ao pessoal do Grupo de Arquitectura e Computac¸ao˜ (Hugo Correia, Sara Proenc¸a, Francisco Freire, Pedro Alfaiate, Bruno Ferreira, Guilherme Ferreira, Inesˆ Caetano e Carmo Cardoso), por todas as sug- estoes˜ e pelo inestimavel´ feedback em artigos e apresentac¸oes.˜ Aos amigos em Tomar (Rodrigo Carrao,˜ Hugo Matos, Andre´ Marques e Rui Santos) e em Lisboa (Diogo da Silva, Nuno Silva, Pedro Engana, Kaguedes, Clara Paiva e Odemira), por terem estado pre- sentes, duma forma ou doutra, nos essenciais momentos de lazer. A` Fundac¸ao˜ para a Cienciaˆ e Tecnologia (FCT) e ao INESC-ID pelo financiamento e acolhimento atraves´ da atribuic¸ao˜ de uma bolsa de investigac¸ao˜ no ambitoˆ dos contratos Pest-OE/EEI/LA0021/2013 e PTDC/ATP-AQI/5224/2012.
    [Show full text]
  • Table of Contents
    Table of Contents Introduction 1.1 Dedication 1.2 Preface 1.3 About Python 1.4 Installation 1.5 First Steps 1.6 Basics 1.7 Operators and Expressions 1.8 Control flow 1.9 Functions 1.10 Modules 1.11 Data Structures 1.12 Problem Solving 1.13 Object Oriented Programming 1.14 Input and Output 1.15 Exceptions 1.16 Standard Library 1.17 More 1.18 What Next 1.19 Appendix: FLOSS 1.20 Appendix: About 1.21 Appendix: Revision History 1.22 Appendix: Translations 1.23 Appendix: Translation How-to 1.24 Feedback 1.25 1 Introduction A Byte of Python "A Byte of Python" is a free book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save text files, then this is the book for you. For Python version 3 This book will teach you to use Python version 3. There will also be guidance for you to adapt to the older and more common Python version 2 in the book. Who reads A Byte of Python? Here are what people are saying about the book: This is the book that got me into programming almost a decade ago. Thank you @swaroopch. You changed my life. -- Stefan Froelich I am writing this email to thank you for the great help your book has done for me! It was a really good book that I enjoyed thoroughly. As a 15 year old who has never done programming before, trying to learn Python online was difficult and I couldn't understand anything.
    [Show full text]
  • Python in a Nutshell Part I: Python, Ipython, Language and OOP
    Python in a Nutshell Part I: Python, ipython, language and OOP Manel Velasco,1 PhD and Alexandre Perera,1;2 PhD 1Departament d'Enginyeria de Sistemes, Automatica i Informatica Industrial (ESAII) Universitat Politecnica de Catalunya 2Centro de Investigacion Biomedica en Red en Bioingenieria, Biomateriales y Nanomedicina (CIBER-BBN) [email protected] [email protected] Introduction to Python for Engineering and Statistics Febraury, 2013 Introduction Working with Python Getting Started With Python Functions and Object Oriented Programming ContentsI 1 Introduction Why Learn Python Python History Installing Python Python Resources 2 Working with Python Workflow ipython vs. CLI Text Editors IDEs Notebook 3 Getting Started With Python Introduction Velasco and Perera Python in a Nutshell Introduction Working with Python Getting Started With Python Functions and Object Oriented Programming ContentsII Basic Types Mutable and immutable Controlling execution flow Exception handling 4 Functions and Object Oriented Programming Defining New Functions Decorators Writing Scripts and New Modules Input and Output Standard Library Object-Oriented Programming Velasco and Perera Python in a Nutshell Introduction Why Learn Python Working with Python Python History Getting Started With Python Installing Python Functions and Object Oriented Programming Python Resources Outline 1 Introduction Why Learn Python Python History Installing Python Python Resources 2 Working with Python Workflow ipython vs. CLI Text Editors IDEs Notebook 3 Getting Started With
    [Show full text]
  • O'reilly Books
    Intellectual Property and Open Source ,ip_roadmap.18464 Page ii Thursday, July 3, 2008 10:38 AM Other resources from O’Reilly Related titles Applied Software Producing Open Source Management Software Hackers & Painters The Cathedral & the Bazaar Open Sources Understanding Open Open Sources 2.0 Source and Free Software Licensing oreilly.com oreilly.com is more than a complete catalog of O'Reilly books. You'll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers inter- ested in open and emerging technologies, including new platforms, programming languages, and operating sys- tems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online reference library for programmers and IT professionals. Conduct searches across more than 1,000 books. Sub- scribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or simply flip to the page you need. Try it today for free. main.title Page iii Monday, May 19, 2008 11:21 AM Intellectual PropertyTomcat ™ andThe Open Definitive Source Guide Jason Brittain and Ian VanF. Darwin Lindberg Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo Intellectual Property and Open Source by Van Lindberg Copyright © 2008 Van Lindberg. All rights reserved. Printed in the United States of America.
    [Show full text]
  • Python in a Hacker's Toolbox
    Python in a hacker's toolbox v. 2016 Gynvael Coldwind Security PWNing Conference, Warszawa 2016 Keynote? Raczej prelekcja techniczna. O prelegencie All opinions expressed during this presentations are mine and mine alone. They are not opinions of my lawyer, barber and especially not my employer. Menu Sandboxing Język i VM Bezpieczeństwo RE Ta prezentacja zawiera fragmenty ● Data, data, data... ● "On the battlefield with the dragons" (+ Mateusz Jurczyk) ● "Ataki na systemy i sieci komputerowe" ● "Pwning (sometimes) with style - Dragons' notes on CTFs" (+ Mateusz Jurczyk) ● "Python in a hacker's toolbox" Język i VM Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Python Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python Enhancement Proposal (w skrócie: PEP) Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Język rozwijany przez Python Software Foundation Python Python Enhancement Proposal (w skrócie: PEP) Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... CPython Brython CLPython Jython HotPy pyjs Python Implementacje PyMite PyPy pyvm SNAPpy RapydScript IronPython tinypy https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Jython Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my... Brython Python Implementacje https://wiki.python.org/moin/PythonImplementations Python 2.6, 2.7, 3, CPython?, IronPython??, Jython???, oh my..
    [Show full text]
  • 1. General Python Presentation : ° Why (Not) Python ? ° History
    1. General Python presentation : ° Why (not) Python ? ° History & Community ° Implementations & bundles (flavors) ° Frameworks & libs 2. Some coding bases 3. Peps & the zen of Python Why (not) Python Why not ? - You need realtime ( < µsec) but check Viper ( http://doc.viperize.it ) - You have very little RAM but Tiny Python = 64K & VM of micropython = 2,4K - You have very little CPU but there are implementations even for Arduino - Compiled code is your God, Interpreted code is your Evil. - You need protected code - You need compatibility with bullshit managers (justification + job-protection) > technical rationality Why (not) Python Why ? - Very high-level, short yet very readable, intuitive syntax Easy to learn (pseudo-code-like) (no funky WTF characters series...follow my eyes). Great for non-trivial business-logic (You still understand while your client is long time lost in his own specs) Maintainable even after 150 last-minute changes (Don't tell me it never happens) Maintainable even after 10,000 lines of code (Maintenance = €) - Totally Free & Truly Open Source (PEPs, PSF, ...) - Portable on most OS, including embed systems, including GUI lib - Many different uses: Small helper-scripts (Any Sys-admins in the room ?) Softs with GUI (Cool to build cross-OS heavy clients) Serious daemons (numerous frameworks & protocol libs, API-Hour being the best) Scripting in other softs (GNU Radio, Blender, OOo, AutoDesk Maya, ArcGIS, GIMP, Minecraft, Corel, Rhino 3D ...) Live data processing in shell (Any mad scientist or mathematician in the room
    [Show full text]
  • An Implementation of Python for Racket
    An Implementation of Python for Racket Pedro Palma Ramos António Menezes Leitão INESC-ID, Instituto Superior Técnico, INESC-ID, Instituto Superior Técnico, Universidade de Lisboa Universidade de Lisboa Rua Alves Redol 9 Rua Alves Redol 9 Lisboa, Portugal Lisboa, Portugal [email protected] [email protected] ABSTRACT Keywords Racket is a descendent of Scheme that is widely used as a Python; Racket; Language implementations; Compilers first language for teaching computer science. To this end, Racket provides DrRacket, a simple but pedagogic IDE. On the other hand, Python is becoming increasingly popular 1. INTRODUCTION in a variety of areas, most notably among novice program- The Racket programming language is a descendent of Scheme, mers. This paper presents an implementation of Python a language that is well-known for its use in introductory for Racket which allows programmers to use DrRacket with programming courses. Racket comes with DrRacket, a ped- Python code, as well as adding Python support for other Dr- agogic IDE [2], used in many schools around the world, as Racket based tools. Our implementation also allows Racket it provides a simple and straightforward interface aimed at programs to take advantage of Python libraries, thus signif- inexperienced programmers. Racket provides different lan- icantly enlarging the number of usable libraries in Racket. guage levels, each one supporting more advanced features, that are used in different phases of the courses, allowing Our proposed solution involves compiling Python code into students to benefit from a smoother learning curve. Fur- semantically equivalent Racket source code. For the run- thermore, Racket and DrRacket support the development of time implementation, we present two different strategies: additional programming languages [13].
    [Show full text]
  • An Implementation of Python for Racket
    An Implementation of Python for Racket Pedro Palma Ramos António Menezes Leitão Contents • Motivation • Goals • Related Work • Solution • Performance Benchmarks • Future Work Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 2 Racket + DrRacket Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 3 Racket + DrRacket Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 4 Racket + DrRacket Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 5 Our goal... Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 6 Our goal... Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 7 Why Python? Python is replacing Scheme in introductory programming courses Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 8 Rosetta IDE Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 9 Rosetta IDE Front ends: Back ends: Rosetta (Racket) AUTOLISP Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 10 • Borrows influences from Lisp • High level, dynamically typed, GC’d • Multiple paradigms • Huge standard library + third-party libraries Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 11 Goals • Correctness + Completeness • Performance • DrRacket Integration • Interoperability with Racket Pedro Ramos & António Menezes Leitão | An Implementation of Python for Racket 12 Related implementations Language(s)
    [Show full text]
  • Complete Guide for Python Programming
    Complete Guide For Python Programming Quick & Easy Guide To Learn Python By: James P. Long ACKNOWLEDGMENTS For my students and friends, who all selflessly helped me in writing this book. Special thanks to those who asked, insisted and assisted me in turning the seminars in this practical form. All Rights Reserved 2012-2015 @ James P. Long Table of Contents Introduction ………………………………………10 Python Versions …………………………………13 Some Commonly used Operations in Python ……………………………………………… 15 Printf Format Strings …………………………20 Python Interactive - Using Python As A Calculator ………………………………………….22 Python Implementations ……………………26 Python Compilers & Numerical Accelerators ………………………………………31 Logical And Physical Line in Python ……34 Python Indentation ……………………………37 Python Standard Library ……………………39 Creating Classes & Objects …………………43 Documenting Your Code ……………………46 Python - Object Oriented Programming 49 Python Database ………………………………..55 Classes ………………………………………………65 Methods ……………………………………………71 Instances …………………………………………..75 Python Database Access …………………….82 Python Networking ………………………….108 Sending Mail in Python …………………….117 Python multithreading …………………….127 Python xml processing …………………….148 Python Programs …………………………….166 Python Program to Add Two Matrices 166 Python Program to Add Two Numbers ………………………………………………………..168 Python Program to Calculate the Area of a Triangle …………………………………………..169 Python Program to Check Armstrong Number …………………………………………..171 Python Program to Check if a Number is Odd or Even …………………………………….173 Python Program to Check if
    [Show full text]
  • A Byte of Python V1.92 (For Python 3.0)
    A Byte of Python v1.92 (for Python 3.0) PDF generated using the open source mwlib toolkit see http://code.pediapress.com/ for more information Python 2 Python Choose your Python version: If you want to learn the current Python 2.x, read If you want to learn the new Python 3.0, read here or [1] [2] [3] here or download the PDF download the PDF [4] You can also buy a printed hardcopy. Introduction 'A Byte of Python' is a book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save text files, then this is the book for you. This book is updated for the new Python 3.0 language. If you are looking for a tutorial on the current Python 2.x version, please download the previous revision of the book [5]. On the same note, if you're wondering whether to learn Python 2.x or 3.x, then read this article by James Bennett [6]. Who Reads 'A Byte of Python'? Here are what people are saying about the book: Feedback From Readers This is the best beginner's tutorial I've ever seen! Thank you for your effort. - Walt Michalik (wmich50-at-theramp-dot-net) You've made the best Python tutorial I've found on the Net. Great work. Thanks! - Joshua Robin (joshrob-at-poczta-dot-onet-dot-pl) Hi, I'm from Dominican Republic. My name is Pavel, recently I read your book 'A Byte of Python' and I consider it excellent!! :).
    [Show full text]
  • A Correlative Scrutiny on Two Programming Dialects: RUBY Vs PYTHON Sarath Chandran, Kochumol Abraham
    International Journal of Engineering and Advanced Technology (IJEAT) ISSN: 2249 – 8958, Volume-9 Issue-3, February, 2020 A Correlative Scrutiny on two Programming Dialects: RUBY Vs PYTHON Sarath Chandran, Kochumol Abraham Abstract: The two most dominant rising programming dialects Ada. Today Ruby has grown to be one of the most popular in reality, Ruby and Python have many features in common. web development language using Ruby on rails. High-level object-oriented coding, interactive shell, standard There is more than one way to do the same thing (Ruby libraries, persistence support are some of the common features of principle) which interprets [13] as Code flexibility which Python and Ruby. However, both vary in their approach to solve is one of the major advantage of Ruby [41]. Programmer can problems because of their syntax and uses. Power of a language define their on syntax for coding. It makes programming is based on the libraries and popularity defines the frameworks that have been used. This research paper primarily focuses on more fun which results in its popularity among programmers the frameworks and libraries of Ruby and Python. Ruby on Rails [30]. Python and Ruby are two competing programming is one of the most powerful framework of Ruby and Django for languages today. Both languages are similar and at the same python. Python is used for many purposes beyond web time they have their own uniqueness [23][28]. Ruby and development such as data science and machine learning Python [5],[8] works on distinctive platform inclusive of computations. A spike in popularity is seen for both Ruby and Mac OS, Windows and various versions of linux [26][27].
    [Show full text]