chris-lovejoy / CodingForMedicine

A series of educational exercises, applying programming to medicine
20 stars 12 forks source link

Beginner Python #3

Closed shivan-s closed 1 year ago

shivan-s commented 1 year ago

I will look into making the 'easy' python stuff :)

chris-lovejoy commented 1 year ago

Okay awesome! Have invited you as a contributor.

I have some initial rough notes in a "Python Principles", happy to share them. Feel free to update the README with your name by that exercise if you're happy to do that one

shivan-s commented 1 year ago

Here is an example: https://www.youtube.com/watch?v=txAbHRz4orA of what I had in mind. It can be made more professional and better. Let me know what you think.

EDIT: a blog post - https://shivan.xyz/posts/programming/zero-to-hundred-in-python/

chris-lovejoy commented 1 year ago

Looks great! 👍

chris-lovejoy commented 1 year ago

And if you could make it a similar format to the 2 exercises currently in the 'exercises' folder, would be awesome. I might write up some documentation on this to help make the formatting more explicit, too, if it would be helpful?

medic-code commented 1 year ago

Great stuff Shivan, I was wondering whether it would be good to build up a little more slowly.

Starting from 1.Data types (String,Numbers, Lists and Dictionaries), 2.Ways to manipulate (variables, looping, methods) 3.Ways to structure the code (functions)

I also think its worth considering introducing a framework to solve problems at a one function level nearer the end. The one I use is called PEDAC that works as well for single functions as multiple functions.

  1. Problem - Identify the problem,, the inputs, outputs and the rules of the problem and any assumptions to make
  2. Examples - Great to clarify a problem and solution
  3. Data Structures - To think about data structures that should be used to help you solve the problem
  4. Algorithm - using plain english look at the steps to go through needed to get to the solution
  5. Code

The focus being understanding the rules of the problem and the algorithm. Having such a framework allows you to solve problems in a structured manner going forward.

A good practical guided exploration towards a goal might me a blood test retriver (Not sure they had this in NHS England, but in NHS Scotland we used the APEX command line tool to retrieve blood tests - Miss those days!).

There's probably a way to include all the available data structures and using looping, storing in variables and separated it into functions that might be quite cool.

shivan-s commented 1 year ago

Hey, @medic-code thanks for your feedback.

I agree with your idea of the framework: it provides a context to learn from rather than "this is a string, this is a function blah blah".

Although, I think @chris-lovejoy has someone working on this already unless you are that someone!

medic-code commented 1 year ago

No worries! Its not me aha. Happy to contribute where I can.

chris-lovejoy commented 1 year ago

Hey Aaron, happy for you to lead on this if you're happy to! Very much agree with the outline above, looks great.

medic-code commented 1 year ago

Yep happy to lead on this. Chris do you have the python principles you mention up above to share ? Send it to aaronsmith1@tutanota.com or if it's a shared document send me a link.

medic-code commented 1 year ago

I've had a chance to look through the python principles draft @chris-lovejoy lots of good stuff to base off of in this so I've adapted and added some extra section headings.

Here's a suggested skeleton for core programming principles

I think I will create a PR after each section to get some feedback. Currently doing some of the introduction information.

Core Principles (High Level)

  1. Introductory information
  2. Basic building blocks (Syntax)
  3. Data and Storing Data
  4. Manipulating Data
  5. Controlling data
  6. Structuring Code
  7. Small Application

Within each section above should try to follow

  1. What we will cover
  2. Theory boxes
  3. Analogy (potential for graphics here)
  4. Examples illustrative of theory
  5. Simple problems the person should attempt with a suggested solution
  6. Suggested solution should both include code and explanations where necessary
  7. More difficult problems (that require practice of a problem solving framework)
  8. Possible small programs (may be a stretch but would be nice to have one in each section)
  9. Summary points to each section
  10. Questions people should be able to answer (both theoretical and can you give me an example of ... type questions)
  11. Additional Questions

I'm thinking about something like an external notion page for the problems to stop it from becoming so large a file or to break this into a few different colabs per section.

Core Principles (Low Level)

Introduction

  1. Intro to Programming Principles
  2. Learning Approach
  3. Problem Solving Approach
  4. What you will achieve at the end

Syntax

  1. Keywords
  2. Statements and Expressions
  3. Identifiers
  4. Comments
  5. Indentation
  6. Python Documentation

Data and Storing Data

  1. Variables 1.1 Naming variables 1.2 Assigning variables 1.3 Variables as pointers 1.4 Equality
  2. Data Types (introducing) 2.1 Strings 2.2 Numbers 2.3 Boolean and Truthiness 2.4 NoneType Collections 2.5 List 2.6 Tuples 2.7 Dictionaries 2.8 Sets
  3. Mutability vs Immutability

Manipulating Data

  1. Operators
  2. Common built in functions/methods (len,print, input,type)
  3. Casting Types and Coercion
  4. String/list/dictionary/num methods

Controlling data

  1. Conditional statements
  2. While and For Looping
  3. List comprehensions

Structuring Code

  1. Functions 1.1 Functions vs Methods 1.2 Declaring a function 1.3 Arguments (Positional, Keyword) 1.4 Return statements 1.5 First class functions and Higher Order Functions 1.6 Pass by reference and Pass by Value 1.7 Side effects
  2. Modules (stretching the confines of a colab)
  3. Namespaces and Scope 3.1 Variable shadowing

Application

  1. Initial idea of a blood test retriver (Something to incorporate manipulating data, controlling it and structuring into functions)
  2. Will want to add a bit of planning aspects to a small project to highlight that projects should have a plan before doing any code.

Summary

  1. Core principles to apply across languages learned.
  2. Further lessons to direct towards.
shivan-s commented 1 year ago

Nice work Aaron. What can we do to help?

On Mon, Feb 27, 2023 at 8:20 AM Aaron Smith @.***> wrote:

I've had a chance to look through the python principles draft @chris-lovejoy https://github.com/chris-lovejoy lots of good stuff to base off of in this so I've adapted and added some extra section headings.

Here's a suggested skeleton for core programming principles Core Principles (High Level) Introductory information Basic building blocks (Syntax) Data and Storing Data Manipulation and Controlling data Structuring Code Small Application

Within each section above should try to follow

  1. What we will cover
  2. Theory boxes
  3. Analogy (potential for graphics here)
  4. Examples illustrative of theory
  5. Simple problems the person should attempt with a suggested solution
  6. Suggested solution should both include code and explanations where necessary
  7. More difficult problems (that require practice of a problem solving framework)
  8. Possible small programs (may be a stretch but would be nice to have one in each section)
  9. Summary points to each section
  10. Questions people should be able to answer (both theoretical and can you give me an example of ... type questions)
  11. Additional Questions

I'm thinking about something like an external notion page for the problems to stop it from becoming so large a file or to break this into a few different colabs per section. Core Principles (Low Level) Introduction

  1. Intro to Programming Principles
  2. Learning Approach
  3. Problem Solving Approach
  4. What you will achieve at the end

Syntax

  1. Keywords
  2. Statements and Expressions
  3. Identifiers
  4. Comments
  5. Python Documentation

Data and Storing Data

  1. Variables and assigning variables
  2. Data Types (introducing) 2.1 Strings 2.2 Numbers 2.3 Boolean 2.4 NoneType Collections 2.5 List 2.6 Tuples 2.7 Dictionaries 2.8 Sets
  3. Casting Types

Manipulation Data

  1. Operators
  2. String/list/dictionary/num operators methods
  3. Common built in functions/methods (len()

Controlling data

  1. Conditional statements
  2. While and For Looping
  3. List comprehensions

Structuring Code

  1. Functions
  2. Modules
  3. Namespace

Application

  1. Initial idea of a blood test retriver (Something to incorporate manipulating data, controlling it and structuring into functions)
  2. Will want to add a bit of planning aspects to a small project to highlight that projects should have a plan before doing any code.

— Reply to this email directly, view it on GitHub https://github.com/chris-lovejoy/CodingForMedicine/issues/3#issuecomment-1445442901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMGDQMZCDGDLVDYSD5DA7WDWZOUIDANCNFSM6AAAAAASRGY5ZM . You are receiving this because you authored the thread.Message ID: @.***>

medic-code commented 1 year ago

Thanks @shivan-s I'm absolutely fine with you taking a section or more of this if you wish! Its a lot to cover. I have some more time after today to start work on it. I've wrote some stuff for the Introduction section and plan on doing the Syntax section in the next few days.

It looks like you've done some work already variables, so you could take a stab at that section if you have the time. My idea around introducing the data types in a small way and not necessarily the methods is that its a lot to take in on a section to include both. I feel its a bit better to be able to know a little bit about the data types and mutability first then talk about methods when we're talking about manipulating data.

None of this is set in stone or indeed think the way I've set it out is the best way, so if you have ideas or ways to improve definitely open to iterative improvement.

shivan-s commented 1 year ago

Awesome! @medic-code, would you like this in a markdown file or a jupyter type notebook?

shivan-s commented 1 year ago

(markdown suits me haha).

shivan-s commented 1 year ago

(markdown suits me haha).

actually, the spec of this project is .ipynb files. So never mind!

medic-code commented 1 year ago

Yep! @chris-lovejoy Just trying to think what might be the best way you'd like for us to contribute to the same exercise.

  1. Create a separate branch and anyone can check the branch out and create commits prior to a PR - Problem being is that it could be that we have a very large PR with contributions by multiple people.
  2. Create separate files for different sections so that anyone can start work and not deal with conflicts, create a small PRs. Eventually we could then combine if necessary the different sections in one exercise (Its going to be a long exercise and my feeling is that it might be better suited if we break down into sections anyways.

I'm sure there's probably more ways we could do this, but just two off the top of my head.

chris-lovejoy commented 1 year ago

Hey guys! Yeah I think .ipynb are quite tricky to collaborate on, so I'd def say having separate files to work on makes sense.

In terms of handling the branching, my thoughts would be:

  1. Make one initial branch for the python principles stuff (which will get merged with main once all python principles stuff done)
  2. Make branches off that initial branch for sub-components of the exercise, and merge back into the branch once sub-components done. these should probably be in different files anyways, and will need combining at the end, so it may also not be necessary to actually do separate branches - I think definitely an option to just have a bunch of files that people are editing simultaneously on the same branch.
medic-code commented 1 year ago

Yep I think that makes sense Chris for sub branches from initial branch. @chris-lovejoy Could you make me a contributor so I can push the initial file / create the remote branch for others to branch out from ?

chris-lovejoy commented 1 year ago

Done

On Saturday, March 4, 2023, Aaron Smith @.***> wrote:

Yep I think that makes sense Chris for sub branches from initial branch. @chris-lovejoy https://github.com/chris-lovejoy Could you make me a contributor so I can push the initial file / create the remote branch for others to branch out from ?

— Reply to this email directly, view it on GitHub https://github.com/chris-lovejoy/CodingForMedicine/issues/3#issuecomment-1454705590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIPTL6MELTHVJRXRUVDU5ODW2MQUXANCNFSM6AAAAAASRGY5ZM . You are receiving this because you were mentioned.Message ID: @.***>

-- Dr Chris Lovejoy MA Hons (Cantab), MB BChir, MSc (ML), MBA, MFCI Data Scientist // Medical Doctor

M: (+44) 7746 247237 / W: chrislovejoy.me http://chrislovejoy.me/

medic-code commented 1 year ago

Thanks @chris-lovejoy. @shivan-s You should be able to see the pythonprincip branch to branch off from. Let me know if you need any help with git!

shivan-s commented 1 year ago

Thanks. I will have a good look in the coming days.

medic-code commented 1 year ago

Sorry everyone, been away from the computer without WiFi. Just to summarise contributions to python principles. I'll be working on the sections assigned to me this week for review. @lawrenceadams @KelvinKramp Not sure if you have the time and would like to contribute to this!

I'll work my way down the sections still needing assigned unless someone wants to assign themselves a section to cover.

Assigned Introduction: @medic-code Syntax: @medic-code Data and Storing Data: @shivan-s (Any update on this section Shivan ?)

Still to need contribution for

Manipulating Data: Controlling Data: Structuring Code: Application:

shivan-s commented 1 year ago

Thank you. I will look into it soon.

medic-code commented 1 year ago

Just to update everyone on progress. I've now pushed on to the remote branch python-principles a section on vocabulary and syntax. I have a section on problem solving written out but want to find a good place to put this naturally rather than out of context at the start. I've also done some scoping work on subheadings for the other sections as I'm writing and figuring out the best layout. I'll push to the remote branch today, or sometime tomorrow depending. I'll start work Data and Storing Data section tomorrow too, I've already written a fair chunk in draft form but need to go through it.

Aim is to try get this complete by end of week hopefully with some breathing room as I always find things to change when writing.

FYI @chris-lovejoy

chris-lovejoy commented 1 year ago

Had a look through this Aaron - looks awesome!

I think that given the scope of this exercise, it's going to make sense to sub-divide it into multiple notebooks - perhaps each of the 6/7 parts will become a notebook in itself. We don't have to divide it up right now though.

medic-code commented 1 year ago

Thanks Chris!

Yeah as I'm going through this, it's becoming apparent separate notebooks might be necessary. I'm trying to just get a WIP done this week, so I can look at it with fresh eyes and add parts/problems and bit more interactivity. So definitely just initial work.

On Fri, Apr 7, 2023 at 9:38 AM ChrisLovejoy @.***> wrote:

Had a look through this Aaron - looks awesome!

I think that given the scope of this exercise, it's going to make sense to sub-divide it into multiple notebooks - perhaps each of the 6/7 parts will become a notebook in itself. We don't have to divide it up right now though.

— Reply to this email directly, view it on GitHub https://github.com/chris-lovejoy/CodingForMedicine/issues/3#issuecomment-1500074690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOKD2E3DXTAD76ZVFTUYIATW77G6VANCNFSM6AAAAAASRGY5ZM . You are receiving this because you were mentioned.Message ID: @.***>

medic-code commented 1 year ago

PR created and being reviewed. I'll close this issue now!