Informatika2-2014/Gyakorlat01

A MathWikiből
(Változatok közti eltérés)
21. sor: 21. sor:
 
* Python interpreter futtatása:
 
* Python interpreter futtatása:
 
<python>
 
<python>
$ <strong>python</strong>       ## Run the Python interpreter
+
$ python        ## Run the Python interpreter
 
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)  
 
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)  
 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
 
Type "help", "copyright", "credits" or "license" for more information.
 
Type "help", "copyright", "credits" or "license" for more information.
>>> <strong>a = 6</strong>       ## set a variable in this interpreter session     
+
>>> a = 6      ## set a variable in this interpreter session     
>>> <strong>a</strong>           ## entering an expression prints its value
+
>>> a          ## entering an expression prints its value
 
6
 
6
>>> <strong>a + 2</strong>
+
>>> a + 2
 
8
 
8
>>> <strong>a = 'hi'</strong>   ## a can hold a string just as well
+
>>> a = 'hi'    ## a can hold a string just as well
>>> <strong>a</strong>      
+
>>> a     
 
'hi'
 
'hi'
>>> <strong>len(a)</strong>     ## call the len() function on a string
+
>>> len(a)      ## call the len() function on a string
 
2
 
2
>>> <strong>foo(a)</strong>     ## try something that doesn't work
+
>>> foo(a)      ## try something that doesn't work
 
Traceback (most recent call last):
 
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
+
   File "", line 1, in ?
 
NameError: name 'foo' is not defined
 
NameError: name 'foo' is not defined
 
>>> ^D          ## type CTRL-d to exit (CTRL-z in Windows/DOS terminal)
 
>>> ^D          ## type CTRL-d to exit (CTRL-z in Windows/DOS terminal)

A lap 2014. február 10., 14:05-kori változata

Tartalomjegyzék

Python

Elmélet

Bevezetés

  • Altalános körben használható
  • Magas szintű programozási nyelv
  • Egyik alap elve az olvasható kód írása tiszta szintaxis használatával
  • Dinamikus interpreter nyelv
  • Sokszor script nyelvként használjuk
  • "Pythonban minden objektum"
  • PEP8
ez_egy_hosszu_fuggvenynev(ez_egy_hosszu_valtozo)
OsztalyNev
  • Python interpreter futtatása:
$ python        ## Run the Python interpreter
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 6       ## set a variable in this interpreter session    
>>> a           ## entering an expression prints its value
6
>>> a + 2
8
>>> a = 'hi'    ## a can hold a string just as well
>>> a     
'hi'
>>> len(a)      ## call the len() function on a string
2
>>> foo(a)      ## try something that doesn't work
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'foo' is not defined
>>> ^D          ## type CTRL-d to exit (CTRL-z in Windows/DOS terminal)

Feladatok

1. Házi Feladat

Személyes eszközök