Problem Set 6: Sentimental

tl;dr

  1. Watch Week 8’s lecture (and Week 6’s and Week 7’s, if you haven’t already).

  2. Port some programs from C to Python.

  3. Analyze some sentiments.

  4. Submit a form.

Help

For help with Weeks 6 – 8 and Problem Set 6:

  • Watch Zamyla’s walkthroughs herein.

  • Start a discussion with classmates.

Getting Started

update50
mkdir ~/workspace/pset6/
cd ~/workspace/pset6/

Problems

All code that you write should be consistent with Style Guide for Python Code, otherwise known as PEP 8.

  1. Implement either of the below exactly as specified but in Python:

    • Mario, less comfortable, in a file called mario.py in pset6/.

    • Mario, more comfortable, in a file called mario.py in pset6/.

  2. Implement either of the below exactly as specified but in Python:

    • Greedy, less comfortable, in a file called greedy.py in pset6/.

    • Credit, more comfortable, in a file called credit.py in pset6/.

  3. Implement any (one) of the below exactly as specified but in Python:

    • Caesar, less comfortable, in a file called caesar.py in pset6/.

    • Vigenère, less comfortable, in a file called vigenere.py in pset6/.

    • Crack, more comfortable, in a file called crack.py in pset6/.

  4. Implement Sentiments in pset6/sentiments/.

No check50 for these!

Hints

  • Be sure to use Python 3, not Python 2.

  • If a program is in a file called, say, foo.py, you can run that program with python foo.py.

  • For Mario, Greedy, Credit, Caesar, Vigenère, and Crack, it is reasonable to look at your own implementations thereof in C and others' implementations thereof in C, including the staff’s implementations thereof (and postmortems) in C. It is not reasonable to look at others' implementations of the same in Python. It is not reasonable to look at others' implementations of Sentiments.

  • Consider this problem set an opportunity not only to port your own prior work from C to Python but to improve upon your earlier designs using lessons learned since!

  • When porting code from C to Python in CS50 IDE, you might want to select View > Layout > Horizontal Split so that you can see both side by side.

  • Insofar as a goal of this problem set is to teach you how to teach yourself a new language, keep in mind that these acts are not only reasonable, per the syllabus, but encouraged toward that end:

    • Incorporating a few lines of code that you find online or elsewhere into your own code, provided that those lines are not themselves solutions to assigned problems and that you cite the lines' origins.

    • Turning to the web or elsewhere for instruction beyond the course’s own, for references, and for solutions to technical difficulties, but not for outright solutions to problem set’s problems or your own final project.

  • You’re welcome to use the CS50 Library for Python, which includes get_float, get_int, and get_string. Just remember to include

    import cs50

    atop your code. Or you can use input and validate users' input yourself.

  • You might find chr and/or ord of help.

  • You might find these references of interest:

Walkthroughs

How to Submit

Be sure you’ve signed up for a GitHub account, per Problem Set 0, and that you’ve logged into and authorized CS50.me at least once, per Problem Set 1!

Step 1 of 2

update50
cd ~/workspace/pset6/
submit50 cs50/2017/x/pset6

Step 2 of 2

Submit this form!

This was Problem Set 6.