Assignment 1
What to Do
- Open this Google Doc.
- Make a copy of the Google Doc in your own Google account by choosing File → Make a Copy.
- Answer each of the questions below in the Google Doc by filling in the blanks marked TODO. Your answers, if not code, should be no more than a few sentences in length each.
Questions
Code
-
In your own words, what’s the difference between machine code and source code?
-
In your own words, what’s a compiler?
Take a closer look at the implications of (not understanding) floating-point imprecision by way of this video.
-
Explain, in a few sentences, how overflow led to the explosion of an Ariane 5 rocket. You might find that nytimes.com/1996/12/01/magazine/little-bug-big-bang.html and users.math.umn.edu/~arnold/disasters/ariane5rep.html offer a bit more detail.
-
Explain, in a few sentences, how floating-point imprecision also led to Patriot missiles’ failure to intercept Scud missiles. You might find that nytimes.com/1991/05/20/world/after-war-army-blaming-patriot-s-computer-for-failure-stop-dhahran-scud.html and archive.gao.gov/t2pbat6/145960.pdf offer a bit more detail.
Python
For the following three (3) Python programs only, you’re welcome to collaborate with a classmate. Take care to work on each program together rather than splitting them between you.
If you’ve never programmed before, not to worry! Do your best to implement each program, but don’t fret if you can’t quite get all three working.
-
In CS50 IDE, create a new file called
pseudorandom.pyand, in that file, implement a program that, quite simply, prints a pseudorandom number between 1 and 10, inclusive. To figure out how, you might find Python’s official documentation, or Stack Overflow, of particular help! -
In CS50 IDE, create a new file called
guess.pyand, in that file, implement a program that picks a pseudorandom number between 1 and 10, inclusive, and asks the user to guess that number. Your program should then print some message, informing the user whether or not their guess was correct. -
In CS50 IDE, create a file called
guesses.py(plural) and, in that file, implement a program that picks a pseudorandom number between 1 and 10, inclusive, and gives the user up to 3 chances to guess that number, each time printing some message, informing the user whether or not their guess was correct.
Debrief
- About how many HOURS would you say you spent on this assignment? Just to set expectations for future students.
How to Submit
- Download your completed assignment as a PDF by choosing File → Download → PDF Document, and save it to your computer.
- Go to CS50 for JDs’s Gradescope page.
- Click Assignment 1.
- Click Submit PDF.
- Click Select PDF and choose your assignment file.
- Click Upload PDF.
- Click the first question in the Question Outline at left, then click the page (or pages) on which your response to that question is located. Repeat this process for the remaining questions.
- Click Submit.
You should see a message that says “Assignment 1 submitted successfully!”
If you run into any trouble with the above steps, email hls@cs50.harvard.edu!