Re: [Tutor] Recommended Resurce or strategy for beginning students

2019-02-21 Thread Matthew Polack
Hi All,

Just wanted to update this thread regarding a resource for beginning
students. We are now 4 weeks into the course and have found an excellent
youtube series that goes from absolute basics.
https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpMMs5lskzBApYXn0bl7emsW

The big advantage for us in a classroom context is that students can work
through this at their own pace using an Ipad to watch videos and then a
computer to code..

I have some students who are flying through the course and are ready for
more advanced topics..others are working more slowly...but all of them are
enthusiastic and engaged...and the beauty of using a series like this is
they can just go onto the harder topics when they are ready.

After we finish this series my plan is then to go onto Mike's excellent
PySimpleGUI resource...https://pysimplegui.readthedocs.io/tutorial/

I'm sure the students will then enjoy the GUI elements of the code.

We'll also use the Turtle import option to add some graphics interactions

We then might look to use a robotics  resource which is GoPiGo
https://www.dexterindustries.com/gopigo-in-python-tutorials/ which gives us
a chance to explore robotics with Python.

The pleasing thing is how keen the students are to keep learning and asking
questions

Thanks again for all your support and ideas!

Matthew Polack

On Tue, Feb 5, 2019 at 3:05 PM David  wrote:

> On Tue, 22 Jan 2019 at 20:30, Matthew Polack
>  wrote:
> >
> > Hi All,
> >
> > In our growing school we're teaching Python programming for the first
> time
> > as an elective subject with Year 9 and 10 students. (Had a dabble at this
> > last year with 3 students in Year 11)
>
> Hi Matthew and other readers,
>
> I wonder if you and any others here involved in classroom/group teaching
> might be interested in this recent presentation that I stumbled across:
>
> https://media.ccc.de/v/35c3-9800-how_to_teach_programming_to_your_loved_ones
>
> The section of this video which motivates me to write here is the two
> minutes
> from 19:00 to 21:00.
>
> What I find most interesting is his motivation mentioned there: he claims
> his
> procedure solves the problem of any students becoming "lost", feeling
> "stuck"
> at any particular step, not knowing what to do next, and unable to proceed
> without guidance.
>
> Quoting from the synopsis:
> The talk is based on many years of research by the Program by Design,
> DeinProgramm, and Bootstrap educational projects, as well as over 30 years
> of personal teaching experience in school, university and industrial
> contexts.
> A word of warning: The resulting approach is radically different from most
> teaching approaches used in universities and schools. In particular, it
> avoids
> teaching purely through examples and expecting students to develop the
> skills to arrive at the solutions on their own. Instead, it teaches
> explicit
> methodology that enables students to solve problems of surprising
> complexity
> on their own, whether they are 11 or 55, whether in a classroom, a training
> facility, or your home. Extensive documentation, material, and software to
> support this methodology is available for free.
>
> For anyone considering watching the whole presentation, I expect that there
> are many other aspects of this presentation to which people here could
> react
> negatively, for example:
>
> 1) The given title is misleading, in my opinion its subtitle would be much
> more
> representative: "Enabling students [by] example-driven teaching".
>
> 2) It recommends against Python, about this I have no opinion (except
> to respect the presenter's experience) and that is not why I am posting it
> here.
>
> 3) It emphasises functional programming style.
>
> 4) Despite possibly having an audience including skilled programmers, in
> the
> second half of the presentation the presenter does not skip quickly over
> the
> concept, but instead he chooses to demonstrate his concept by reproducing
> the same deliberate steps that he would use in a classroom of students
> with low ability.
>
> Despite all these possibly alienating aspects, and possibly others, I'm not
> really interested in those aspects, because they're not useful to me and so
> I choose to ignore them, instead focussing on what might be useful.
>
> Years ago I spent about a decade teaching undergraduate engineering
> students, from that context I consider this interesting and relevant.
> This presenter mentions that he has 30 years of of experience
> and commitment to teaching this subject, and considers most of his
> efforts a "failure" (at 02:00). Learning from such a person can save other
> practitioners a great deal of effort.
>
> So I felt that this was worth sharing here, I hope negative reactions
> or distractions don't distract from possibly useful information.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

Re: [Tutor] Recommended Resurce or strategy for beginning students

2019-02-21 Thread Mike Barnett
Congratulations!!

When going through PySimpleGUI….
There are some tutorial videos if your students like to learn that way.
https://www.reddit.com/r/Python/comments/9nvdmw/tutorial_beginning_as_in_your_first_time_gui/

And be sure and check out the new PySimpleGUIWeb implementation.

https://www.reddit.com/r/Python/comments/ar3x3b/embedding_entire_python_guis_in_webpages_with/

The latest Cookbook takes advantage of this early port of PySimpleGUIWeb 
running in the repl.it environment.

It uses repl.it to show how to implement various cookbook Recipes.

The PySimpleGUI account for Repl.it is https://repl.it/@PySimpleGUI which is 
where you’ll find a number of example programs that run using PySimpleGUIWeb.

Repl.it is AMAZING!  They’re even doing AI contests on there.  Imagine doing 
Python AI programs without Python even being installed on your computer.

Now your students can program PySimpleGUI code on an iPad if they really 
wanted.  Any browser window will work with repl.it.

You can write your PySimpleGUI code one time and run it on the web, tkinter, 
Qt, or WxPython all by just changing the import statement (in theory).

The downside is that each port is a little bit further along than the others.  
Tkinter is pretty much done.  Qt is in Alpha.  Wx is Pre-Alpha.  Web is 
Engineering release.

For doing the basics, PySimpleGUIWeb does remarkably well.  I’m able to use it 
to demonstrate PySimpleGUI concepts in a way that any reader can understand and 
execute without  even needing Python installed on their computer.

It’s Remi, by the way, that is the magic 
behind PySimpleGUIWeb.



@mike

From: Matthew Polack 
Sent: Wednesday, February 20, 2019 10:35 PM
To: David ; Mike Barnett ; 
Alan Gauld 
Cc: tutor@python.org
Subject: Re: [Tutor] Recommended Resurce or strategy for beginning students

Hi All,

Just wanted to update this thread regarding a resource for beginning students. 
We are now 4 weeks into the course and have found an excellent youtube series 
that goes from absolute basics.
https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpMMs5lskzBApYXn0bl7emsW

The big advantage for us in a classroom context is that students can work 
through this at their own pace using an Ipad to watch videos and then a 
computer to code..

I have some students who are flying through the course and are ready for more 
advanced topics..others are working more slowly...but all of them are 
enthusiastic and engaged...and the beauty of using a series like this is they 
can just go onto the harder topics when they are ready.

After we finish this series my plan is then to go onto Mike's excellent 
PySimpleGUI 
resource...https://pysimplegui.readthedocs.io/tutorial/

I'm sure the students will then enjoy the GUI elements of the code.

We'll also use the Turtle import option to add some graphics interactions

We then might look to use a robotics  resource which is GoPiGo 
https://www.dexterindustries.com/gopigo-in-python-tutorials/
 which gives us a chance to explore robotics with Python.

The pleasing thing is how keen the students are to keep learning and asking 
questions

Thanks again for all your support and ideas!

Matthew Polack

On Tue, Feb 5, 2019 at 3:05 PM David 
mailto:bouncingc...@gmail.com>> wrote:
On Tue, 22 Jan 2019 at 20:30, Matthew Polack
mailto:matthew.pol...@htlc.vic.edu.au>> wrote:
>
> Hi All,
>
> In our growing school we're teaching Python programming for the first time
> as an elective subject with Year 9 and 10 students. (Had a dabble at this
> last year with 3 students in Year 11)

Hi Matthew and other readers,

I wonder if you and any others here involved in classroom/group teaching
might be interested in this recent presentation that I stumbled across:
https://media.ccc.de/v/35c3-9800-how_to_teach_programming_to_your_loved_ones

Re: [Tutor] Help Please

2019-02-21 Thread DL Neil

Mario,

On 21/02/19 3:30 AM, Mario Ontiveros wrote:

Hello,
 I am new to python and have been stuck on this for a while. What I am 
trying to do is to remove rows with void, disconnected, and error on lines. The 
code I have does that, the only problem is that it removes my header because 
void is in header. I need to keep header.
with open("PSS.csv","r+") as f:
 new_f = f.readlines()
 f.seek(0)
 for line in new_f:
 if "Void" not in line:
 if "Disconnected" not in line:
 if "Error" not in line:
  f.write(line)
 f.truncate()



Would it be 'safer' to create a separate output file?

Rather than reading the entire file (easily managed if short, but 
unwieldy and RAM-hungry if thousands of records!), consider that a file 
object is an iterable and process it one line/record at a time.


with open( ... ) as f:
header = f.readline()
# deal with the header record
for record in f:
function_keep_or_discard( record )
#etc


In case it helps you to follow the above, and possibly to learn other 
applications of this thinking, herewith:-


An iterable matches a for-each-loop very neatly (by design). It consists 
of two aspects: next() ie give me the next value (thus for each value in 
turn), and the StopIteration exception (when next() asks for another 
value after they have all been processed). The for 'swallows' the 
exception because it is expected. Hence, you don't need to try...except!


Something a lot of pythonistas don't stop to consider, is that once code 
starts iterating an object, the iteration does not 'reset' until 
"exhausted" (unlike your use of f.seek(0) against the output file). 
Accordingly, we can use a 'bare' next() to pick-out the first (header) 
record and then pass the rest of the job (all the other next()s) to a 
for-each-loop:


with open( ... ) as f:
header = next( f )  # grab the first record
# deal with the header record
for record in f:# iterate through the remaining records
#etc

--
Regards =dn
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Conway's game of life

2019-02-21 Thread Phil
Thank you for reading this.

It's been quite some time since I've attempted any programming and since
I've recently discovered PySimpleGUI I thought I'd have a go at programming
Conway's game of life. Unfortunately, I've been stuck trying to resolve a
logic error for the past couple of weeks using the IDLE debugger and a host
of print statements. I can see where the error occurs but I cannot see why.

The error occurs at the point of the third generation which results in a
fixed pattern of cells rather that a looping pattern. It's always the third
generation no matter what the initial pattern is. The error seems to be in
the area where the rules are applied.

Can a kind person spend a couple of minutes to find what is most likely an
obvious error?

import sys
import PySimpleGUI as sg
import time
import numpy

layout = [[sg.Graph(canvas_size=(400, 400),
   graph_bottom_left=(0,20),
   graph_top_right=(20,0),
   background_color='white',
   key='graph')],]

window = sg.Window('The game of life',
grab_anywhere=True).Layout(layout).Finalize()

graph = window.FindElement('graph')

board_size = 8#20

dead = 0
live = 1

#board = [[dead] * board_size for i in range(board_size)]
#next_board = [[dead] * board_size for i in range(board_size)]

board = numpy.zeros(board_size * board_size, dtype='i').reshape(board_size,
board_size)
#board = numpy.zeros((board_size, board_size))

#next_board = numpy.zeros((board_size, board_size))
next_board = numpy.zeros(board_size * board_size,
dtype='i').reshape(board_size, board_size)


'''
seed board[y][x] NOT board[x][y]
'''

board [1][1] = dead
board [1][2] = live
board [1][3] = dead

board [2][1] = dead
board [2][2] = dead
board [2][3] = live

board [3][1] = live
board [3][2] = live
board [3][3] = live

def display():
event, values = window.Read(timeout = 0)

for y in range(board_size):
for x in range(board_size):

if (board[x][y]) == 0:
graph.DrawCircle((y,x), 5, line_color='white',
fill_color='red')#'white')

else:
graph.DrawCircle((y,x), 5, line_color='black',
fill_color='black')

window.Refresh()

time.sleep(2)

def count_live_neighbours(x, y):
live_neighbours = 0

debug_cell = board[x][y]

for i in range(-1, 2):
for j in range(-1, 2):
live_neighbours += board[x + i][y + j]

#don't count the cell at x = 0 and y = 0
live_neighbours -= board[x][y]

return live_neighbours

#display initial board
display()

while True:
#clear next_board
#next_board.fill(0)

for x in range(1, board_size - 1):
for y in range(1, board_size - 1):

live_neighbours = count_live_neighbours(x, y)

'''
Any live cell with fewer than two live neighbors dies, as if by
underpopulation.
Any live cell with two or three live neighbors lives on to the next
generation.
Any live cell with more than three live neighbors dies, as if by
overpopulation.
Any dead cell with exactly three live neighbors becomes a live cell, as if
by reproduction.

'''
if board[x][y] == 1 and live_neighbours <  2:
next_board[x][y] = 0

elif board[x][y] == 1 and live_neighbours >  3:
next_board[x][y] = 0

elif board[x][y] == 0 and live_neighbours == 3:
next_board[x][y] = 1

elif board[x][y] == 1 and (live_neighbours == 2 or
live_neighbours == 3):
next_board[x][y] = 1

#else:
#next_board[x][y] = board[x][y]

board = next_board

display()





-- 
Regards,
Phil
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor