Sentimental
tl;dr
-
Port
hello.c
tohello.py
. -
Port
mario.c
tomario.py
. -
Port
cash.c
tocash.py
orcredit.c
tocredit.py
. -
Port
caesar.c
tocaesar.py
,vigenere.c
tovigenere.py
, orcrack.c
tocrack.py
.
Problems
-
Implement the below exactly as specified but in Python:
-
Hello, in
pset6/hello/hello.py
-
-
Implement either of the below exactly as specified but in Python:
-
Implement either of the below exactly as specified but in Python:
-
Implement any (one) of the below exactly as specified but in Python:
Walkthroughs
Note that, among these walkthroughs, Cash was previously called Greedy. Also, for Crack, passwords can be up to 5 chars long (not 4 as shown).
Testing
Correctness
check50 cs50/2018/x/sentimental/hello
check50 cs50/2018/x/sentimental/mario/less
check50 cs50/2018/x/sentimental/mario/more
check50 cs50/2018/x/sentimental/cash
check50 cs50/2018/x/sentimental/credit
check50 cs50/2018/x/sentimental/caesar
check50 cs50/2018/x/sentimental/vigenere
As before, afraid there’s no check50
for Crack, lest it spoil the fun!
Style
style50 hello.py
style50 mario.py
style50 cash.py
style50 credit.py
style50 caesar.py
style50 vigenere.py
style50 crack.py
Hints
-
Be sure to use Python 3, not Python 2. The former is installed by default on CS50 IDE, but if Google leads you to Python’s official documentation, be sure the URLs begin with https://docs.python.org/3/, not https://docs.python.org/2/.
-
If a program is in a file called, say,
foo.py
, you can run that program withpython foo.py
. -
For Hello, 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.
-
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 these problems 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
, andget_string
. Just remember to include any offrom cs50 import get_float from cs50 import get_int from cs50 import get_string
atop your code. Or you can use
input
and validate users' input yourself. -
You might find these references of interest: