Difference between revisions of "Learn Python the Hard Way 12b"

From Hackerspace.gr
Jump to: navigation, search
(Description matches the one from the (cancelled) LPtHW12 meeting)
 
 
(One intermediate revision by the same user not shown)
Line 22: Line 22:
  
 
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_11
 
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_11
 +
 +
 +
 
----
 
----
 
|eventowner=User:Ebal
 
|eventowner=User:Ebal
 
|url=http://learnpythonthehardway.org/book/
 
|url=http://learnpythonthehardway.org/book/
|from=2015/09/28 06:30:00  
+
|from=2015/09/28 18:30:00  
|till=2015/09/28 08:30:00  
+
|till=2015/09/28 20:30:00  
 
|location=38.01694322164, 23.731269990513
 
|location=38.01694322164, 23.731269990513
 
}}
 
}}
 +
 +
 +
 +
Notes
 +
 +
Boolean Operators:
 +
 +
<pre>
 +
    and
 +
    or
 +
    not
 +
    != (not equal)
 +
    == (equal)
 +
    >= (greater-than-equal)
 +
    <= (less-than-equal)
 +
    True
 +
    False
 +
</pre>
 +
 +
 +
extra notes:
 +
 +
Truthy values (programming)
 +
latest operator will return of non Boolean value
 +
 +
BE CAREFUL
 +
 +
<pre>
 +
In [45]: "test" and "test"
 +
Out[45]: 'test'
 +
 +
In [46]: 1 and 1
 +
Out[46]: 1
 +
 +
In [47]: "1" and "1"
 +
Out[47]: '1'
 +
 +
In [48]: "test" or "test"
 +
Out[48]: 'test'
 +
 +
In [49]: "" or "katiallo"
 +
Out[49]: 'katiallo'
 +
 +
In [50]: "test" and "test2"
 +
Out[50]: 'test2'
 +
 +
In [51]: "katiallo" or ""
 +
Out[51]: 'katiallo'
 +
 +
In [52]: "hello" or ""
 +
Out[52]: 'hello'
 +
 +
In [53]: "" and 1
 +
Out[53]: ''
 +
 +
In [54]: "2" and 1
 +
Out[54]: 1
 +
 +
In [55]: "" and 1
 +
Out[55]: ''
 +
 +
In [56]: [] and 1
 +
Out[56]: []
 +
</pre>
 +
 +
 +
not equal
 +
 +
<pre>
 +
Python has deprecated <> in favor of !=, so use !=
 +
</pre>
 +
 +
 +
arithmetic
 +
 +
<pre>
 +
In [8]: cats = 0
 +
 +
In [9]: cats += 5
 +
 +
In [10]: cats
 +
Out[10]: 5
 +
 +
In [11]: cats =+ 5
 +
 +
In [12]: cats
 +
Out[12]: 5
 +
 +
In [13]: cats = +5
 +
 +
In [14]: cats
 +
Out[14]: 5
 +
 +
In [15]: cats += 5
 +
 +
In [16]: cats =+ 5
 +
 +
</pre>
 +
 +
so operator must be before assignment (=)
 +
 +
another example
 +
 +
<pre>
 +
In [17]: cats *= 5
 +
 +
In [18]: cats
 +
Out[18]: 25
 +
 +
In [24]: cats = 5
 +
 +
In [25]: cats **=3
 +
 +
In [26]: cats
 +
Out[26]: 125
 +
</pre>

Latest revision as of 20:07, 28 September 2015

Learn python the hard way.jpg

external link
Starts Organizer
Mon 28 Sep 2015 18:30
Ends Event Owner
Mon 28 Sep 2015 20:30 User:Ebal
  • Κάθε Δευτέρα, 18:30-20:30
  • Συναντήσεις για εκμάθηση προγραμματισμού σε python.

Θα είναι υπό την μορφή study group, δηλαδή όλοι θα μαθαίνουμε παρέα και δεν θα υπάρχει κάποιος "δάσκαλος". Οι συναντήσεις είναι ανοιχτές σε όλες και όλους - αρκεί να φέρεις το laptop σου! Απευθύνονται σε ανθρώπους που θέλουν να ξεκινήσουν με python κι άρα θα είναι αρκετά εισαγωγικές. Η μοναδική δέσμευση είναι να τηρηθεί αυστηρά το ωράριο (δηλαδή εάν κάποιος ή κάποια αργήσει, να μην μας ζητήσει να γυρίσουμε πίσω για να καλύψουμε κάτι που έχουμε ήδη πει).


  • Στις προηγούμενες συναντήσεις έχουμε καλύψει μέχρι και την:

Exercise 26: Congratulations, Take a Test!

http://learnpythonthehardway.org/book/ex26.html


Η σελίδα της προηγούμενης συνάντησης με μερικές σημειώσεις:

https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_11






Notes

Boolean Operators:

    and
    or
    not
    != (not equal)
    == (equal)
    >= (greater-than-equal)
    <= (less-than-equal)
    True
    False


extra notes:

Truthy values (programming) latest operator will return of non Boolean value

BE CAREFUL

In [45]: "test" and "test"
Out[45]: 'test'

In [46]: 1 and 1 
Out[46]: 1

In [47]: "1" and "1"
Out[47]: '1'

In [48]: "test" or "test" 
Out[48]: 'test'

In [49]: "" or "katiallo"
Out[49]: 'katiallo'

In [50]: "test" and "test2"
Out[50]: 'test2'

In [51]: "katiallo" or "" 
Out[51]: 'katiallo'

In [52]: "hello" or ""
Out[52]: 'hello'

In [53]: "" and 1
Out[53]: ''

In [54]: "2" and 1
Out[54]: 1

In [55]: "" and 1
Out[55]: ''

In [56]: [] and 1
Out[56]: []


not equal

Python has deprecated <> in favor of !=, so use !=


arithmetic

In [8]: cats = 0 

In [9]: cats += 5

In [10]: cats 
Out[10]: 5

In [11]: cats =+ 5 

In [12]: cats 
Out[12]: 5

In [13]: cats = +5 

In [14]: cats
Out[14]: 5

In [15]: cats += 5

In [16]: cats =+ 5

so operator must be before assignment (=)

another example

In [17]: cats *= 5 

In [18]: cats
Out[18]: 25

In [24]: cats = 5 

In [25]: cats **=3

In [26]: cats
Out[26]: 125