Beta Pleated Chic
  • Home
  • About
  • Blog
  • Podcast
  • Work with us

Learning to Code: My First Coding Bootcamp

2/8/2016

0 Comments

 
by Heidi Norton
​

Last weekend, I attended a two-day Python  bootcamp put on by the Penn Institute for Computational Science. I’ve been making incremental progress learning Python for almost a year now but haven’t needed to code very often, which makes it hard to pick up quickly. I’m finally reaching the point in my research where I actually need to write and modify code to analyze my data (yay!), so I thought attending a (free) Python bootcamp would be a perfect way to help me work out some of the kinks and confusion I’ve faced from trying to teach myself to code. I wasn’t sure what to expect, but when I arrived, I found a room full of ~40 grad students and post-docs from all kinds of backgrounds. There was a group of bioengineering PhD students, including me, but there were also people from linguistics and mechanical engineering and the school of medicine. Our instructor was a former Penn grad student and post-doc who now works in industry but is passionate about teaching people how to use Python well (here's a link to his website). The bootcamp moved at a great pace for me and I found the overall experience to be a great way to solidify my coding skills. 

I know everyone’s experiences learning to code or learning a new coding language are unique, and people run into different challenges depending on their background. I’d like to share with you one of my biggest challenges in learning Python so far and two solutions I came across during the coding bootcamp.
 
Challenge: Python is run through the terminal. Once you’ve run the script, all the variables are wiped away and it can be really challenging to troubleshoot. 
Picture
In this example, I ran a script ‘test.py’, which defines some variables x, y, and z, then prints them out in different ways. Once I’ve run the script, I type ‘x’ in the command line to try to see its value and I get the error ‘x: command not found’. The variables I defined in my function are cleared out of memory once it’s finished running, so I can’t easily see what my variables were without adding additional print lines to my script and running the script again.
 
This was particularly challenging for me because my first intro to Python was through running long, involved scripts that someone else wrote and trying to modify it to suit my needs. I ran the script over and over again with slight modifications and a ton of print statements to try to figure out what on earth was going on.

Solution 1: Spyder
Picture
Spyder is a Python development environment that is part of the Anaconda package.
You can pull up your current working directory, the script you are editing, and a python ‘Console’ all in the same workspace. Once you want to run the script, you save it and hit the green arrow (similar to Matlab). The part that gets me excited is that the variables aren’t wiped away after the script is done, so you can type any of the variables defined in the script into the console and get information about them. 
Picture
​There’s also a variable explorer similar to Matlab that lets you examine the type and contents of your variables. 
Picture
 The one annoying thing about Spyder is that you can’t treat the python console totally like a terminal; it can’t take in system arguments like file names, so you might have to modify the way your script takes inputs in order for it to run smoothly in Spyder. All in all, I think Spyder will help me to make much faster progress in setting up and understanding data structures in my code and troubleshooting errors involving variables. 

Solution 2: iPython (or Jupyter) 
Picture
Jupyter can be used in a lot of programming languages, including python. It’s a web application that integrates with a directory of your choice and allows you to write and run small blocks of code. You can run each block independently or run everything together. You can even display your plots immediately below the code that was used to generate them. In my initial experience using iPython/Jupyter, it seems that it isn’t as good at troubleshooting variables as is Spyder, but it’s awesome at testing out small chunks of code, especially for generating plots.

What are some of your biggest headaches in learning to code? Have you found any good solutions? Write about them in the comments!

0 Comments



Leave a Reply.

    Archives

    May 2017
    March 2017
    November 2016
    October 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015
    February 2015
    January 2015
    December 2014
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014

    Categories

    All
    Academia
    Advice
    Advisor
    Anastasia Voevodin
    Anatomy
    Applications
    Art
    Ask A PI
    Audio
    Bioengineering
    Blogs
    Books
    Business
    Cancer
    Celebrity
    Coding
    Collaboration
    Community
    Companies
    Company
    Conferences
    Contributors
    CV
    Dance
    Decision
    Diversity
    Education
    Engineering
    Entertainment
    Environment
    Experience
    Family
    Father
    FDA
    Fertility
    Fitness
    Founder
    Fun
    Funding
    Games
    Genomics
    Gifts
    Grad Gal Sal
    Graduate School
    Grants
    Guest
    Guest Post
    Hardware
    Health
    Heidi Norton
    Historical
    Holiday
    Hot Topic
    Inspiration
    Interview
    Interviews
    Jena Barnes
    Katherine Stafford
    Lab
    Leadership
    Math
    MD
    Medical School
    Medicine
    Megan Sperry
    Movies
    Networking
    News
    NIH
    Non-profit
    NSF
    Nursing
    Office
    Organization
    Organizations
    Outreach
    Parents
    Pharma
    PhD
    Phuong Nguyen
    Podcast
    Podcasts
    Policy
    Politics
    Productivity
    Professor
    Q&A
    Qualifying Exam
    Reading
    Recommendations
    Research
    Review
    Rotations
    Sally Winkler
    Science
    Scientific Waste
    Shopping
    Social Media
    Sponsored
    Sports
    Start-up
    Statistics
    Summer
    Teaching
    Technology
    Toys
    Translational Research
    Travel
    TV
    Under The Microscope
    University Of Pennsylvania
    Video
    Volunteering
    Writing

Powered by Create your own unique website with customizable templates.
  • Home
  • About
  • Blog
  • Podcast
  • Work with us