Learning to Code: Week 9 – Python?


CS50 Week 5

  • Watched lecture 1 (56m)

Found this website that indexes the popularity of various programming languages: http://www.tiobe.com/tiobe_index

Trying Daily Programmer Challenge #273 – Degree

  • Learned about scanf and its capabilities. Very cool. http://beej.us/guide/bgc/output/html/multipage/scanf.html
  • Wrote up the program on scratch paper while on break at work.
  • Everything seems to be working okay so far except when I use strcmp on “rd” it still thinks “dr” is acceptable?
  • Well it seems I should’ve read more about strcmp

  • Program is working now for degree and radians. I may try to tackle the bonus as well a little bit later as it would only require adding in more formulas.
  • A function would probably help that just used all that stuff and returned the conversion just to look cleaner?
  • I am not sure how to deal with decimals or rounding here. The output for rd is just to a whole number, but if I do %.2f I’ll always get a trailing 180.00.
  • Google to rescue again for my question above. I can use %g! http://stackoverflow.com/questions/9628645/use-printf-to-format-floats-without-decimal-places-if-only-trailing-0s
  • Still not sure how well %g will work well since precision is impaired.
  • http://stackoverflow.com/questions/277772/avoid-trailing-zeroes-in-printf WTF O_o
  • For the bonus attempt I’m going to write a function to convert any of the provided inputs. For converting Kelvin I’ll just have the function call itself to convert F to C or C to F.
  • Also that way you can add other units down the line like inches to feet or inches to cm.
  • http://www.almanac.com/content/temperature-conversion
  • Kept getting 0 as an output in my program, then remembered my functions have to return something. Doh.
  • My program works for all bonuses except I can’t seem to do a recursive call on my own function. Perhaps since there isn’t a base case…maybe it goes on forever somehow?
  • Debugging my function continuously calls itself instead of calling the cf one and returning a value…
  • Here is my code so far with the recursive call causing a segmentation fault 🙁




  • Also I’m not sure, but I probably should be reversing the ACTUAL string and not putting it into another variable? All the stuff I’ve seen on StackOverflow so far that deal with the same question have been doing that.
  • So from reading a better way to do this is to take the first index and last index and swap. Then go to the next two letters and swap until you hit a middle letter or your indexes swap using pointers to swap the letters.
  • Ok I finally got a functional reverse function in C and it only took 2 hours!
  • That problem was a bitch and half to solve, but I did learn quite a few things especially a little bit more clarification about pointers.
  • While I didn’t use it in my FOR loop I also learned you can decrement/increment more than one variable at a time. Pretty baller imo.
  • Bitwise video: https://www.youtube.com/watch?v=d0AwjSpNXR0
  • Reverse function in C posted here
  • There is no check for a null string.
  • Did another really quick and simple leet code problem here: Nim Game
  • Solution is:


Today I didn’t do much coding, but I did do a little more research into this 4 week intensive online Python class/workshop.

This course seems really compelling to me especially if I can finish CS50 and run through a bit of Python before I start it. It looks intense and it gives me access to mentors almost anytime I want to ask questions.

It doesn’t seem that expensive either if I didn’t get a scholarship thing. It would require 4 mandatory days a week, but if I want to get more serious and get more time in I feel that is what is required.

Then again it could just be some cash grab BS course, which I don’t want. It’s hard to tell who is a legit good developer when I don’t know shit. 🙁


  • Didn’t get anything done today, but in the future I would LOVE to take this master’s degree program at GA Tech online. http://www.omscs.gatech.edu/explore-oms-cs
  • Maybe just to prove to myself that I can do it. Do anything I set my mind to.