Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming with Python Episode 3 Example Suggestion #762

Open
CRWayman opened this issue Nov 25, 2019 · 3 comments
Open

Programming with Python Episode 3 Example Suggestion #762

CRWayman opened this issue Nov 25, 2019 · 3 comments

Comments

@CRWayman
Copy link

@CRWayman CRWayman commented Nov 25, 2019

In Episode 3 of Programming with Python, there is an exercise which shows that as a for loop iterates through a string of the five vowels, a variable is updated. I have found that this exercise skips a few logical steps, and that users who are new to Python struggle to understand the outcome of this loop.

I recommend augmenting the loop slightly so that instead of

length = 0
for vowel in 'aeiou':
    length = length + 1
print('There are', length, 'vowels')

You would have

length = 0
for vowel in 'aeiou':
    length = length + 1
    print(length)
    print(vowel)
print('There are', length, 'vowels')

This would provide a sort of hard-coded enumeration example that could show learners how the steps occur on each iteration, and really drive home the idea that loops are moving through each character in a string. It will only help learners reinforce ideas that are taught earlier in the lesson through repetition.

http://swcarpentry.github.io/python-novice-inflammation/03-loop/index.html

@ldko
Copy link
Contributor

@ldko ldko commented Jan 10, 2020

Hi @CRWayman, I think your suggestion in this issue would be a good addition. Not only does it help clarify what is happening, but it also shows that you can execute multiple lines of code within the for loop, which I don't think is shown in this episode's content. Do you have any thoughts about using print(length, vowel) to show the output of each iteration on one line rather than doing the two print statements individually? We welcome a PR to address this issue. Thank you!

@CRWayman
Copy link
Author

@CRWayman CRWayman commented Jan 16, 2020

Hello! I agree that the combination would be better as a single line print statement, I also think it's a good way to reiterate to beginners that you can print multiple variables in a print statement. I'm not sure how to do this as a pull request, are there instructions on how to do this? I wouldn't want to mess anything up. :)

@maxim-belkin
Copy link
Contributor

@maxim-belkin maxim-belkin commented Jan 16, 2020

You can make changes using the GitHub's web interface:

  1. Navigate to the _episodes folder:
    https://github.com/swcarpentry/python-novice-inflammation/tree/gh-pages/_episodes
  2. Click on the episode you'd like to change:
    https://github.com/swcarpentry/python-novice-inflammation/blob/gh-pages/_episodes/03-matplotlib.md
  3. Click on the Edit (pencil) icon

Screen Shot 2020-01-16 at 11 05 04

  1. Change the file as you feel fit.
  2. Scroll to the bottom of the page and:
    Screen Shot 2020-01-16 at 11 09 13
  • Add a title for your changes
  • (Optional) explain what you did and why in detail
  • (Important) Select "Create a new branch for this commit and start a pull request"
  • Choose a name for the created Git branch. Remember it as you might need it in the future if maintainers (us) ask you to make any changes further down the road.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants