Turn on thread page Beta
    • Thread Starter
    Offline

    4
    ReputationRep:
    I'm studying Python as part of my master's, and I'm struggling with some basic programming problems, such as how to construct a Pascal's triangle or how to calcualate a Fibonacci sequence. I'm starting to think that maybe I just don't get the programming logic and I'm wondering if there's anything I can do about it or if I should just give up.

    What was your experience as beginners? Did you struggle with these kinds of problems too? Does it get any easier with practice?

    Also, it'd be great if you could recommend any good books/websites for beginners. Thanks in advance.
    Offline

    20
    ReputationRep:
    I've been programming to some degree since 2012 and I still suck at it.
    Online

    19
    ReputationRep:
    Yeah, I kinda sucked when I started (still kinda do tbh) but to improve you just do more things and practice, as cliche as that sounds it's the truth.
    Projecteuler was quite nice.
    Offline

    6
    ReputationRep:
    I went through the code academy course (it’s free) and that teaches you loads. Then I just messed around with scenarios I created in my head. Eventually, you’ll get the hang of it, patterns will start appearing everywhere and it will become second nature.
    Posted on the TSR App. Download from Apple or Google Play
    Offline

    20
    ReputationRep:
    well the field is dominated by males, maybe it's for a reason...

    Spoiler:
    Show

    girls aren't cut out for programming? :P
    • Thread Starter
    Offline

    4
    ReputationRep:
    (Original post by ANM775)
    well the field is dominated by males, maybe it's for a reason...

    Spoiler:
    Show


    girls aren't cut out for programming? :P

    Is this supposed to be ironic?
    Offline

    20
    ReputationRep:
    (Original post by ANM775)
    well the field is dominated by males, maybe it's for a reason...

    Spoiler:
    Show


    girls aren't cut out for programming? :P

    :cookie:
    Offline

    20
    ReputationRep:
    (Original post by stellaluna24)
    Is this supposed to be ironic?




    You tell me

    overcome your programming woes and prove me wrong
    Offline

    19
    ReputationRep:
    (Original post by stellaluna24)
    I'm studying Python as part of my master's, and I'm struggling with some basic programming problems, such as how to construct a Pascal's triangle or how to calcualate a Fibonacci sequence. I'm starting to think that maybe I just don't get the programming logic and I'm wondering if there's anything I can do about it or if I should just give up.

    What was your experience as beginners? Did you struggle with these kinds of problems too? Does it get any easier with practice?

    Also, it'd be great if you could recommend any good books/websites for beginners. Thanks in advance.
    What masters is it you are doing??

    I struggled initially as I was putting the cart before the horse, i.e. I was simply typing out code with no rhyme or reason and seeing what stuck to the wall. Obviously this was me teaching myself, and it wasn't a great approach. When I started learning to think computationally, that helped me solve problems in a better manner. It's important to get away from thinking "How do I do this in python?" and thing "How do I do this logically, then how do I write it in Python?". If you get the former right, the latter will be more straightforward. Ask yourself this: Can you write your solution out in pseudo code? If you can't, you need to do some more work on developing computational thinking skills.

    I would recommend this book, it's beginner friendly and has some simply Python exercises in it too. More than that, it discusses developing computational thinking without actually writing out any code initially:

    https://www.amazon.co.uk/Computation...KNHN1BFK07PMCT
    Online

    18
    ReputationRep:
    (Original post by stellaluna24)
    I'm studying Python as part of my master's, and I'm struggling with some basic programming problems, such as how to construct a Pascal's triangle or how to calcualate a Fibonacci sequence. I'm starting to think that maybe I just don't get the programming logic and I'm wondering if there's anything I can do about it or if I should just give up.

    What was your experience as beginners? Did you struggle with these kinds of problems too? Does it get any easier with practice?

    Also, it'd be great if you could recommend any good books/websites for beginners. Thanks in advance.
    That's pretty standard for the majority of people starting out learning programming for the first time. The things you mentioned are all about Computational thinking which isn't something that you're likely to learn while you're growing up through childhood - it's a whole different mindset that requires you to think about problems step-by-step.

    The key is simply to practice until it feels natural. When you're starting out thinking about any kind of problem, then a good first step is to write it down on paper before even thinking of switching on your computer, and consider each of the logical steps you need to solve a problem one at a time.

    Problems like the Fibonacci sequence or Pascal's triangle require that you understand exactly how those sequences actually work - it's not enough just to know enough about them to be able to write those numbers down, you need to focus on doing doing everything the "long way" by precisely and accurately writing down all of the steps that you would take to find the next number in that sequence.

    When writing things down on paper It's often a good idea to try repeating those same steps multiple times - think carefully about the inputs and outputs too, and maybe write them down in some kind of 'truth table' - for example:

    Fibonacci sequence truth table:
    Code:
    Step    1st    2nd    Result
      1      1      1       2
      2      1      2       3
      3      2      3       5
      4      3      5       8
      5      5      8       13
    A truth table can be helpful because it hints at the kinds of variables you'd need in your program to model it - i.e. based on the truth table above, you can immediately see that a fibonacci algorithm most likely needs 4 variables which will change over time, one for each column in the table. (Step, 1st, 2nd and Result)

    Have a look at this intro course on edX written by MIT teaching staff, which is focused on using Python to learn this mindset. There are a lot of decent video lectures and a lot of exercises to test your problem solving ability: https://www.edx.org/course/introduct...itx-6-00-1x-11
    (It'll take you back to the beginning, but if you're struggling with Python and with thinking algorithmically, it might be worth going back to the beginning anyway).
    • Community Assistant
    Online

    20
    ReputationRep:
    Community Assistant
    As someone who finds programming comes rather naturally I'm not sure how helpful this will be. But I find the best thing to do is break the program down into smaller, more manageable chunks that you can solve individually and then work out how it all fits together. It also helps to write out the program in some sort of English like way so that you can link what the program does to the actual code required to do it.

    It's a very basic example but let's say you wanted to write a program that takes a name as an input and outputs Hello, followed by that name. What do the English like steps look like?
    1. Ask user for their name
    2. Read name in, store it in a variable
    3. Output a string saying Hello concatenated with the name variable

    Immediately looking at this you realise that you now need a variable declaration (or not depending on language). So you now have:
    0. Declare variables
    1. Ask user for their name
    2. Read name in, store it in a variable
    3. Output a string saying Hello concatenated with the name variable

    Maybe you decide to do a test and make sure the user enters letters for their name, not numbers. You'd slot that in as well:
    0. Declare variables
    1. Ask user for their name
    2. Read name in, check it is alphabetic, store it in a variable
    3. Output a string saying Hello concatenated with the name variable

    You can of course break these steps down further if required but next you'd start applying code to it. So how do you declare a variable, how do you write a prompt to the screen and so on.

    Taking the Fibonacci example, you'd start by defining what a Fibonacci sequence looks like. These sorts of problems tend to involve patterns, so you pull out the pattern and look at how you implement it. For example, a Fibonacci sequence follows a rule of the last 2 numbers added together make the next number. So what information do you need to complete that? Well you need to store the last two numbers, which could mean 2 variables. You also need to perform a sum calculation.

    1. Get last two numbers, put in variables lastNumber and secondLastNumber
    2. Add two numbers together, put in variable nextNumber

    Maybe you then decide that you want an array to store each term

    1. Create array, populate with starting numbers
    2. Get last two numbers from array, put in variables lastNumber and secondLastNumber
    3. Add two numbers together, put in variable nextNumber
    4. Write nextNumber to array

    Then you decide that the next stage is to run this program repeatedly, which means a loop. Decide some conditions (does the user enter, does it run a finite number of times, etc.) and add the loop to your steps

    1. Create array, populate with starting numbers
    2. Start loop
    3. Get last two numbers from array, put in variables lastNumber and secondLastNumber
    4. Add two numbers together, put in variable nextNumber
    5. Write nextNumber to array
    6. Advance the loop in some way

    This isn't meant to be a good example of how to write code for a Fibonacci sequence but it should demonstrate how you can build your program up over time. Start by writing out what it is you need in English then convert that into a series of instructions that a computer might vaguely understand. Then start coding it.

    Honestly the only way you get better at programming is to actually program and solve problems. Not understanding syntax is fine, we all Google stuff like that. But the actual problem solving, thinking like a computer aspect is something that if you are not naturally good at needs to be built up by consistently doing work. Even when you've got bigger problems, start small and work your way up
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: March 6, 2018

University open days

  1. University of Bradford
    University-wide Postgraduate
    Wed, 25 Jul '18
  2. University of Buckingham
    Psychology Taster Tutorial Undergraduate
    Wed, 25 Jul '18
  3. Bournemouth University
    Clearing Campus Visit Undergraduate
    Wed, 1 Aug '18
Poll
How are you feeling in the run-up to Results Day 2018?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.