Skip to content

Final Exam Problems

Theo Chupp edited this page Jan 23, 2018 · 5 revisions

Instructions

For the final exam, choose three of the problems below and write a program that finds the solution.
Each problem is graded out of 20 points; 15 points for solving the problem for the first goal, 5 points for making the program flexible enough to solve the secondary goals without changing.

Any online reference material may be used; using code written as part of the course is encouraged!

Challenges

Problem 1

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

Primary: What is the 10,001st prime number?
Secondary: What are the 20,001st & 30,001st prime number?

Example:

def nth_prime(n):
   ...
   return prime

print nth_prime(10001) == ?

Problem 2

By listing the first seven numbers in the Fibonacci sequence: 0, 1, 1, 2, 3, 5, and 8, we can see that 2 and 8 are even.

Primary: What are the first 10 even numbers in the Fibonacci sequence?
Secondary: What are the first 20 odd numbers in the Fibonacci sequence?

Problem 3

A Pythagorean triplet is a set of three natural numbers, a < b < c, where, a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2

Primary: What is the first Pythagorean triplet where a < 10?
Secondary: What is the first Pythagorean triplet where a < 15?

Problem 4

A bullet is shot horizontally from a rifle. At what time does it hit the ground? And what is the total displacement from the starting point?

Primary: Shot at 300 m/s from a height of 15m, when acceleration due to gravity is 9.81 m/s^2?
Secondary: Shot at 450 m/s from a height of 25m, when acceleration due to gravity is 4.5 m/s^2?

Problem 5

Sorting algorithms are fun: https://www.facebook.com/TEDEducation/videos/1369636223049580/
Use one of the algorithms described in the video to sort a list of strings by length.

Primary: What is the sorted version of ["hello", "hi", "how are you?", "v good", "nice"]?
Secondary: What is the sorted version of ["five", "six", "seven", "eight-teen?", "nope!"]?

Clone this wiki locally