-
Notifications
You must be signed in to change notification settings - Fork 12
Problems
Sean Purdon edited this page Feb 3, 2015
·
2 revisions
Problems are due at 5pm on the Monday of the given weeks.
- Hello, World (was: "Introduction")
- print the string
'Hello, World!'
- print the string
- Asking for Input (was: "Variable Assignment")
- input a string, then print it back with some minor change (e.g. add
!!!to the end, or print it out twice or something).
- input a string, then print it back with some minor change (e.g. add
- Asking for a Number (new problem)
- input an integer representing a number of hours, output the number of minutes in that many hours (i.e.
60 * n). [*]
- input an integer representing a number of hours, output the number of minutes in that many hours (i.e.
- If Statements 1
- input an integer, print its absolute value using an if statement (enforced by static checker).
- If Statements 2
- input a string (guaranteed to be a single lowercase letter), print
"vowel"or"consonant"as appropriate.
- input a string (guaranteed to be a single lowercase letter), print
- If Statements 3
- input an integer
n, print one of the strings"positive","negative","zero".
- input an integer
- While Statements
- input an integer
n, print the sum of integers from0up to but not includingn.
- input an integer
- While using If
- input two integers, print the number of integers between them which are divisible by 3 or 5. [**]
- While using Break
- repeatedly input "passwords" until the correct password is entered (
hunter2), then break and print "Correct". On all the invalid strings, print "Wrong password".
- repeatedly input "passwords" until the correct password is entered (
- Using Functions
- as usual (
m = 2*(n+1)with functions).
- as usual (
- Writing a Function
- write a function which accepts two parameters, and returns the number of integers between them which are divisible by 3 or 5. Students will be hinted to reuse solution to previous question.
Footnotes:
[*] If the student forgets to turn input into an int, they'll get their input string repeated 60 times, leading to a fun debugging exercise.
[**] I was really tempted to replace this with something analogous like "count the number of factors of a number", which would be a really nice question, but for the students it will be less concrete as to how % works for checking divisibility (I feel like n % i == 0 is more confusing than n % 3 == 0).
(Bonus "too hard" question I made up, but feel free to throw it in a tutorial or something: input a number n, print out a message indicating whether it is perfect, deficient, or abundant)