Difference between revisions of "Learn Python the Hard Way 09"
(Created page with "{{Event |logo=Learn python the hard way.jpg |what=Learn Python the Hard Way |tagline= * Κάθε Δευτέρα, 18:00-20:00 * Συναντήσεις για εκμάθησ...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 21: | Line 21: | ||
* Στις προηγούμενες συναντήσεις έχουμε καλύψει μέχρι και την: | * Στις προηγούμενες συναντήσεις έχουμε καλύψει μέχρι και την: | ||
− | '''Exercise | + | ''' Exercise 21: Functions Can Return Something ''' |
− | Η σελίδα της προηγούμενης συνάντησης ( | + | Η σελίδα της προηγούμενης συνάντησης (8η) με μερικές σημειώσεις: |
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08 | https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08 | ||
Line 45: | Line 45: | ||
− | * We have previously covered exercises till | + | * We have previously covered exercises till 21 (including ''' Exercise 21: Functions Can Return Something ''') |
− | The page for the previous meeting (# | + | The page for the previous meeting (#08) with some notes: |
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08 | https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08 | ||
Line 56: | Line 56: | ||
''These notes are from Lesson 09'' | ''These notes are from Lesson 09'' | ||
+ | |||
+ | '''Exercise 24: More Practice''' | ||
<pre> | <pre> | ||
+ | #!/usr/bin/python2 | ||
+ | |||
+ | print0 = "Let's practice everything." | ||
+ | print print0 | ||
+ | |||
+ | print1 = 'You \'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' | ||
+ | print print1 | ||
+ | |||
+ | poem = """ | ||
+ | \tThe lovely world | ||
+ | with logiv so firmly planted | ||
+ | cannot discern \n the needs of love | ||
+ | nor comprehend passion from intuition | ||
+ | and requires an exaplantion | ||
+ | \n\t\twhere there is none. | ||
+ | """ | ||
+ | |||
+ | print2 = "--------------" | ||
+ | print print2 | ||
+ | print poem | ||
+ | print print2 | ||
+ | |||
+ | five = ( ( 10 - 2 ) + ( 3 - 6 ) ) | ||
+ | |||
+ | print "This should be five: %s" % five | ||
+ | print "This should be five: %d" % five | ||
+ | print "This should be five: %r" % five | ||
+ | |||
+ | # define function with name: secret_formula | ||
+ | # takes one argument with name: started | ||
+ | def secret_formula ( started ): | ||
+ | # PLZ dont DO IT, dont declare global variables | ||
+ | # global ebal | ||
+ | jelly_beans = started * 500 | ||
+ | jars = jelly_beans / 1000 | ||
+ | crates = jars / 100 | ||
+ | return jelly_beans, jars, crates, 2000*1000 | ||
+ | |||
+ | start_point = 10000 | ||
+ | beans, jars, crates, ebal = secret_formula ( start_point ) | ||
+ | |||
+ | print "" | ||
+ | print "ebal: " + str ( ebal ) | ||
+ | print "ebal: %d " % ebal | ||
+ | print "ebal: %s " % ebal | ||
+ | print "ebal:", ebal | ||
+ | print "" | ||
+ | |||
+ | print "With a starting point of: %d" % start_point | ||
+ | print "We 'd have %d beans, %d jars, and %d crates." % ( beans, jars, crates ) | ||
+ | |||
+ | start_point = start_point / 10 | ||
+ | |||
+ | print "We can also do that this way:" | ||
+ | print "We 'd have %d beans, %d jars, and %d crates. %d " % secret_formula ( start_point ) | ||
+ | |||
</pre> | </pre> | ||
Latest revision as of 19:20, 27 July 2015
external link |
Starts | Organizer |
---|---|---|
Mon 27 Jul 2015 18:00 | ||
Ends | Event Owner | |
Mon 27 Jul 2015 20:00 | User:Ebal |
- Κάθε Δευτέρα, 18:00-20:00
- Συναντήσεις για εκμάθηση προγραμματισμού σε python.
Θα είναι υπό την μορφή study group, δηλαδή όλοι θα μαθαίνουμε παρέα και δεν θα υπάρχει κάποιος "δάσκαλος". Οι συναντήσεις είναι ανοιχτές σε όλες και όλους - αρκεί να φέρεις το laptop σου! Απευθύνονται σε ανθρώπους που θέλουν να ξεκινήσουν με python κι άρα θα είναι αρκετά εισαγωγικές. Η μοναδική δέσμευση είναι να τηρηθεί αυστηρά το ωράριο (δηλαδή εάν κάποιος ή κάποια αργήσει, να μην μας ζητήσει να γυρίσουμε πίσω για να καλύψουμε κάτι που έχουμε ήδη πει).
- Θα ακολουθήσουμε την παρακάτω ύλη: http://learnpythonthehardway.org/book/
Έλα εγκαίρως/νωρίς αν θες να βρεις ελεύθερη θέση :)
- Στις προηγούμενες συναντήσεις έχουμε καλύψει μέχρι και την:
Exercise 21: Functions Can Return Something
Η σελίδα της προηγούμενης συνάντησης (8η) με μερικές σημειώσεις:
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08
- Every Monday at 18.00-20:00
- python enthusiasts will try to learn programming "the hard way" !
The meetings will be in study group format, meaning that we will all learn together and there won't be a tutor. Meetings are open to everyone - just bring your laptop! They are for people that want to start learning python, so we will cover some introductory material. The only requirement is to be punctual (so if a person comes later than 18:00 please don't ask us to cover material that we have already gone through).
- Learning resource: http://learnpythonthehardway.org/book/
Come early if you want to ensure that you'll find a space to place your laptop :)
- We have previously covered exercises till 21 (including Exercise 21: Functions Can Return Something )
The page for the previous meeting (#08) with some notes:
https://www.hackerspace.gr/wiki/Learn_Python_the_Hard_Way_08
These events are based on peer2peer education
These notes are from Lesson 09
Exercise 24: More Practice
#!/usr/bin/python2 print0 = "Let's practice everything." print print0 print1 = 'You \'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' print print1 poem = """ \tThe lovely world with logiv so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an exaplantion \n\t\twhere there is none. """ print2 = "--------------" print print2 print poem print print2 five = ( ( 10 - 2 ) + ( 3 - 6 ) ) print "This should be five: %s" % five print "This should be five: %d" % five print "This should be five: %r" % five # define function with name: secret_formula # takes one argument with name: started def secret_formula ( started ): # PLZ dont DO IT, dont declare global variables # global ebal jelly_beans = started * 500 jars = jelly_beans / 1000 crates = jars / 100 return jelly_beans, jars, crates, 2000*1000 start_point = 10000 beans, jars, crates, ebal = secret_formula ( start_point ) print "" print "ebal: " + str ( ebal ) print "ebal: %d " % ebal print "ebal: %s " % ebal print "ebal:", ebal print "" print "With a starting point of: %d" % start_point print "We 'd have %d beans, %d jars, and %d crates." % ( beans, jars, crates ) start_point = start_point / 10 print "We can also do that this way:" print "We 'd have %d beans, %d jars, and %d crates. %d " % secret_formula ( start_point )