Python? programski jezik Wikipedia:



Similar documents
Introduction to Python

Python Basics. S.R. Doty. August 27, Preliminaries What is Python? Installation and documentation... 4

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Postojeći Mail Account u Outlook Expressu (podešavanje promjena):

PYTHON Basics

Crash Dive into Python

Computational Mathematics with Python

Introduction to Python

Introduction to Python for Text Analysis

Postprocessing with Python

Simulation Tools. Python for MATLAB Users I. Claus Führer. Automn Claus Führer Simulation Tools Automn / 65

Computational Mathematics with Python

Computational Mathematics with Python

Basic Python by examples

Python for Scientific Computing.

Exploring Algorithms with Python

2! Multimedia Programming with! Python and SDL

Welcome to Introduction to programming in Python

Python. Python. 1 Python. M.Ulvrova, L.Pouilloux (ENS LYON) Informatique L3 Automne / 25

Scientific Programming, Analysis, and Visualization with Python. Mteor 227 Fall 2015

Scientific Programming in Python

CRASH COURSE PYTHON. Het begint met een idee

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

Python programming guide for Earth Scientists. Maarten J. Waterloo and Vincent E.A. Post

Python for Computational Science and Engineering

Exercise 4 Learning Python language fundamentals

Crash Dive into Python

Web Programming Step by Step

Chemical and Biological Engineering Calculations using Python 3. Jeffrey J. Heys

6.170 Tutorial 3 - Ruby Basics

Computational Science and Engineering in Python

Exercise 1: Python Language Basics

Uputstva za HTC. Sadržaj : 1. HTC HD HTC Snap HTC Smart HTC Legend HTC Desire HTC Magic 10

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

Introduction to Python

Introduction to Python

Postupak konfiguracije ADSL modema ZTE u Routed PPPoE modu Detaljni opis konfiguracije

Part VI. Scientific Computing in Python

ESPResSo Summer School 2012

Profiling, debugging and testing with Python. Jonathan Bollback, Georg Rieckh and Jose Guzman

Computational Physics With Python. Dr. Eric Ayars California State University, Chico

Assignment 2: Option Pricing and the Black-Scholes formula The University of British Columbia Science One CS Instructor: Michael Gelbart

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

Software Tool Seminar WS Taming the Snake

Sorting. Lists have a sort method Strings are sorted alphabetically, except... Uppercase is sorted before lowercase (yes, strange)

Availability of the Program A free version is available of each (see individual programs for links).

Modeling with Python

Podešavanje klijenata

CSC 221: Computer Programming I. Fall 2011

Nicolas P. Rougier PyConFr Conference 2014 Lyon, October 24 25

NaviCell Data Visualization Python API

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

SUNPY: PYTHON FOR SOLAR PHYSICS. AN IMPLEMENTATION FOR LOCAL CORRELATION TRACKING

PIC 10A. Lecture 7: Graphics II and intro to the if statement

E-LEARNING IN BUSINESS

Introduction to Python and Pylab

Tentative NumPy Tutorial

Data Science. Brian Sletten

Obfuscation: know your enemy

B&K Precision 1785B, 1786B, 1787B, 1788 Power supply Python Library

Object Oriented Software Design

CIVIL ENGINEERING PROJECTS REALIZATION MANAGEMENT UDC 725.4(045)=20. Slobodan Mirković

Instruction Set Architecture of Mamba, a New Virtual Machine for Python

NetworkX: Network Analysis with Python

Business Intelligence. 10. OLAP, KPI ETL December 2013.

Based on: Google searches for language tutorials

Apache Thrift and Ruby

6. Control Structures

Wrocław University of Technology. Bioinformatics. Borys Szefczyk. Applied Informatics. Wrocław (2010)

MTH 437/537 Introduction to Numerical Analysis I Fall 2015

Programming and Scientific Computing in

Introduction to Python. Heavily based on presentations by Matt Huenerfauth (Penn State) Guido van Rossum (Google) Richard P. Muller (Caltech)...

ANSA and μeta as a CAE Software Development Platform

Introduction Installation Comparison. Department of Computer Science, Yazd University. SageMath. A.Rahiminasab. October9, / 17

Introduction to Python for Econometrics, Statistics and Data Analysis. Kevin Sheppard University of Oxford

Some programming experience in a high-level structured programming language is recommended.

Introduction to. Marty Stepp University of Washington

Works. Works Quick Reference Guide. Creating and Managing Reports

Python Programming: An Introduction to Computer Science

Python Lists and Loops

A Comparison of C, MATLAB, and Python as Teaching Languages in Engineering

1.- L a m e j o r o p c ió n e s c l o na r e l d i s co ( s e e x p li c a r á d es p u é s ).

UQC103S1 UFCE Systems Development. uqc103s/ufce PHP-mySQL 1

An introduction to Python Programming for Research

Outline. multiple choice quiz bottom-up design. the modules main program: quiz.py namespaces in Python

Python CS1 as Preparation for C++ CS2

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to

Android Based Appointment Scheduler and Location Helper using file operation

FEEG Applied Programming 5 - Tutorial Session

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1

Functional Programming in C++11

Arduino Lesson 17. Sending Movement Detector

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

How to search, organize and manage data?

Comp151. Definitions & Declarations

Transcription:

Python, I deo

Python? programski jezik Wikipedia: Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive. Its use of indentation for block delimiters is unique among popular programming languages. The reference implementation of Python (CPython) is free and open source software and has a community-based development model, as do all or nearly all of its alternative implementations. CPython is managed by the non-profit Python Software Foundation.

Python?? interpreter, scripting language po tome nalik na BASIC (nekada), Octave,... nema kompilacije i linkovanja, vrlo brze probe sporije od C-a ali se dobro povezuje sa C-om jako moćne i raznovrsne biblioteke (pyserial, numpy, matplotlib, sympy,... ) jednostavna sintaksa opšta namena free!!! jako dobro podržan, razvija se, rasprostranjen Google, Youtube,... svaka distribucija GNU/Linux-a ga ima

Python??? Guido van Rossum, December 1989 masovno se uči kao prvi programski jezik: MIT, CU Boulder,... radi pod raznovrsnim platformama, sve koje se kod nas sreću obuhvaćene vrlo objektno orijentisan, mada ne mora da se koristi vrlo moćni tipovi podataka lako se prave novi tipovi podataka

Python, kako nabaviti? GNU/Lin GNU/Linux: već ima interpreter, sigurno provera: komandna linija, python Python 2.7.8 (default, Oct 20 2014, 15:05:19) [GCC 4.9.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. nešto valja dovući iz repository: IDLE IPython numpy scipy matplotlib pylab (sve prethodno) python-serial Sympy Spyder...

Python, kako nabaviti? win Windows: http://python.org/ odaberete platformu, dovucete, instalirate za win je IDLE included ostalo? http://www.enthought.com/ ipython+numpy+scipy+matplotlib+... Canopy, zapravo PyLab pyserial, SourceForge, http://pyserial.sourceforge.net/ Sympy, http://sympy.org/en/index.html Spyder, http://code.google.com/p/spyderlib/...

Python, 2 ili 3? forking, 3 je nov jezik 3 nema backward compatibility nisu prevelike razlike (print, za početak) problem sa već napisanim programima problem ako se oslanjate na već postojeće programe koristim numpy, matplotlib,... pylab predajem verziju 2 verziju 3 učite lako

Python, dokumentacija http://www.python.org/doc/, sve što treba http://ocw.mit.edu/, kurs 6.00 i 6.189 isto, edx, počinje 07.01.2015. http: //openbookproject.net/thinkcs/python/english2e/ http: //greenteapress.com/thinkpython/thinkpython.html još mnogo free resursa, realno je samo #1 potrebno izbor izlistan na sajtu predmeta

Python, dokumentacija, realno Ako ne učite programiranje, već programski jezik: http://www.python.org/doc/ A4, pdf, zip, 10.5 MB Python 2.7.8, 29.10.2014. tutorial.pdf, Python Tutorial, 128 strana reference.pdf, The Python Language Reference, 123 strane library.pdf, The Python Library Reference, 1411 strana

Python, počinjemo, kalkulator Pokrenete IDLE, kako god znate (kom. lin., dash,... ) osnovne operacije: 2+2 2-3 2*3 a sada iznenađenje: 3/4*100 3.0/4.0*100.0 3.0/4*100 3./4*100

Python, da raščistimo celobrojno deljenje help(type) type type() type(3) type(3.0) type(3.) type(10/3) type(10.0/3) type(10/3.) type(10./3.) ovde se Python 3.x.x razlikuje!!!

Python, mislili ste da je sa deljenjem gotovo? 10.0/3.0 10.0//3.0-10.0//3.0-10/3

Python, stepenovanje i long 2ˆ3 3ˆ2 3ˆ3 10ˆ10 2**3 2 ** 3 3 ** 2 10 ** 10 type(10**10) 3**64 type(3**3) type(3**64)

Python, ostatak pri celobrojnom deljenju 10%3 11%3 12%3 t=54+12 print t type(t) s=t/60 m=t%60 print s print m print s, m print proteklo je, s, sat i, m, minuta

Python, uvod u da raščistimo ˆ, operatori poređenja 2 == 2 2==2 3 == 2 2!= 3 2!= 2 2 <> 2 2 <> 3 2 > 3 2 < 3 2 >= 1 2 >= 2 2 >= 3 2 <= 1 2 <= 2 2 <= 3

Python, logičke operacije, ;, \ i # type(true); type(false) a = True b = False type(a) a and b # logicko i not a a and a a or not a a or (not a) a or \ not b # logicko ne # ovako se nastavlja red

Python, zapisi brojeva 012 0o12 0O12 0x35 0X35 0b11 0B11

Python, konverzija zapisa brojeva oct(10) hex(53) bin(3)

Python, da konačno raščistimo ˆ, operacije nad bitima a = 0b0101 a b = 0b0011 b a & b bin(a & b) bin(a b) bin(a ^ b) bin(0) bin(~0) bin(2) bin(~2) ~2 2 << 1 2 << 4 32 >> 2 3 >> 1

Python, a sada nesto sasvim drugačije: kompleksni brojevi j*j 1j*1j 2J * 2J type(1j) abs(3+4j) complex(1,2) a = 2 + 3j type(a) a.real a.imag a.conjugate() a * a.conjugate() del a type(a)

Python, malo ozbiljnija matematika, moduli sin(1) import math type(math) dir(math) help(math) help(math.sin) math.sin(1) math.e math.pi math.sin(math.pi/2) math.exp(math.pi*1j)+1 math.cos(math.pi) + 1j * math.sin(math.pi) + 1

Python, namespaces del math import math as m m.sin(m.pi / 4) ** 2 m.exp(1) - m.e del m from math import * sin(pi / 4) ** 2 exp(1) - e e e = 32 e pi pi = 14 pi

Python, assignment operators a = 1 a += 1 a *= 2 a /= 2 a -= 4 a **= 3 a %= 3-8 / 3 a = 11.0 a //= 3

Python, funkcije def pdv(x): return x * 1.20 type(pdv) pdv(100) pdv(150)

Python, funkcije, help def pdv(x): ovo je funkcija koja racuna pdv return x * 1.20 pdv(100) help(pdv)

Python, funkcije, help u više redova def pdv(x): ovo je funkcija koja racuna pdv a pdv je porez na dodatu vrednost return x * 1.20 pdv(100) help(pdv)

Python, funkcije, opcioni argumenti def pdv(x, stopa = 20): return x*(1 + stopa/100) pdv(100) pdv(150) def pdv(x, stopa = 20): return x * (1 + stopa/100.) pdv(100) pdv(150) pdv(100, stopa=23) pdv(100, 23) del pdv pdv(10)

Python, kontrola toka def parnost(n): if n/2*2 == n: print paran else: print neparan parnost(4) parnost(5) parnost(4.2) parnost(5.1)

Python, ispitivanje tipa def parnost(n): if type(n)!= "<type int >": print argument nije ceo broj return if n/2*2 == n: print paran else: print neparan parnost(4.2) parnost(4) parnost(3) type(4) type(type(4)) type("<type int >")

Python, ispitivanje tipa, sada radi def parnost(n): if str(type(n))!= "<type int >": print argument nije ceo broj return if n/2*2 == n: print paran else: print neparan parnost(4.2) parnost(4) parnost(3)

Python, ispitivanje tipa, može i ovako def parnost(n): if type(n)!= type(1): print argument nije ceo broj return if n/2*2 == n: print paran else: print neparan parnost(4.2) parnost(4) parnost(3) parnost(4.)

Python, konverzije tipova i još ponešto del parnost int(-4.2) int(4.2) long(_) float(_) float(5) divmod(10, 3) divmod(12, 3) pow(2, 8) 2 ** 8 str(float(2**8))

Python, liste a = [1, 2, 5, 6] type(a) a[0] a[1] a[2] a[3] a[4] a[-1] a[-2] a[-3] a[-4] a[-5] len(a)

Python, liste, slicing and mutability a[1:3] a[1 : 2] a[1 : - 2] a[2 : ] a[:2] a[:-2] a[3] = 7

Python, liste, dodavanje i brisanje elemenata a + 9 a + [9] a = a + [9] len(a) del a[(len(a) - 1)] del a[1] len(a)

Python, liste, metodi append i extend a = [1, 2, 3, 4] a.append(5) b = [6, 7] a.append(b) len(a) del a[5] a.extend(b) len(a) del a[5:]

Python, liste, range a = range(5) len(a) a = range(4, 10) len(a) a = range(3, 10, 2) a = range(10, 0, -2)

Python, stack a = [] type(a) a.append(1) a.append(2) a.append(3) a.pop() a.pop() a = range(10) a.pop(3)

Python, liste, insert a = range(10) a.insert(3, 4) a.insert(0, 1) a.insert(len(a), kraj )

Python, liste, reverse, sort a = range(10) a.reverse() a.reverse() a = [3, 4, 2, 1] a.sort()

Python, liste, brojanje i brisanje a = [3, 2, 3, 1, 4, 3, 2, 2, 5, 2] a.count(2) a.count(3) a.remove(3) a.count(3) a.remove(3) a.remove(3) a.remove(3)

Python, in operator 3 in a 4 in a a.remove(4) 4 in a

Python, liste, index metod a.index(2) a.index(5) a.index(1) a.index(3)

Python, aliases a = 3 b = a a is b a == b b += 1 a == b a is b

Python, aliases with lists a = [1, 2, 3] b = a a is b a == b b[1] = 0 a == b a is b c = a[:] c == a c is a c[1] = 2 c == a print c

Python, matrice a = [[1, 2], [3, 4]] len(a) len(a[1]) [1][1] [0][0]

Python, inicijalizacija nizova a = [] a = [0] * 10 a = [[1] * 3] * 3

Python, for petlja a = range(10) for i in a: print i + 1, /, len(a)

Python, for petlja, over string a = neobicno bas for znak in a: print znak

Python, if-else a = abrakadabra b = for znak in a: if znak!= a : b += znak else: b += _ print b

Python, if-elif-else a = abrakadabra b = for znak in a: if znak == a : b += _ elif znak == k : b += * else: b += znak print b