Skip to content
Sean Purdon edited this page Feb 3, 2015 · 2 revisions

Problems

Problems are due at 5pm on the Monday of the given weeks.

Introduction (Wk 3)

  • Hello, World (was: "Introduction")
    • print the string 'Hello, World!'
  • 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).
  • 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). [*]
  • 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.
  • If Statements 3
    • input an integer n, print one of the strings "positive", "negative", "zero".
  • While Statements
    • input an integer n, print the sum of integers from 0 up to but not including n.
  • 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".
  • Using Functions
    • as usual (m = 2*(n+1) with functions).
  • 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)

Abstract Data Types (Wk 4)

Classes and Objects (Wk 5)

Classes, Error Handling and I/O (Wk 6)

Class Design (Wk 7)

Inheritance (Wk 8)

GUI (Wk 9)

Recursion (Wk 11)

Functional Programming (Wk 13)