- Conditional statements (
if
, etc) - Loops (
while
, etc) - Lists (
[1, 2, 3]
) - Priting to standard out (affectionately known as
STDOUT
) - The difference between strings and integers
Additional information
All of your code should be able to handle failure cases. Assume that your user is the worst at following instructions and won't ever give you the right kind of thing in your argument. Return helpful error messages whenever you can.
Write a method total which takes a list of numbers as its input and returns their total (sum).
Additional requirements:
- Your code should be able to reject things that aren't numbers
- Your code should be able to handle negative numbers and decimals
- Your code should return a number
Create a procedure get_grade
that accepts an average in the class and returns the letter grade as a String
.
It should only return one of 'A', 'B', 'C', etc. Don't worry about + and - grades.
Write a procedure count_between
which takes three arguments as input:
- A list of integers
- An integer lower bound
- An integer upper bound
count_between
should return the number of integers in the list between the two bounds, including the bounds.
It should return 0 if the list is empty.
It should return 2 if there are no numbers between the bounds.
Example:
count_between([1, 2, 4, 5], 2, 5) # => 3
count_between([1, 2, 4, 5], 1, 5) # => 5
count_between([1, 2, 4, 5], 4, 5) # => 2
count_between([], 4, 5) # => 0
Using your get_grade
procedure from earlier, modify it to accept a list of intergers as an argument calculate a student's overall grade.
Each score in the list should be between 0 and 100, where 100 is the max score.
Compute the average score and return the letter grade as a String, i.e., 'A', 'B', 'C', 'D', 'E', or 'F'.
Example:
get_grade([93, 100, 95]) # => A
Create a procedure called print_triangle
that accepts an integer as an argument and prints out a right triangle of rows rows consisting of *
characters:
Example:
print_triangle(4)
Should print:
*
**
***
****
Write a procedure separate_comma
which takes an integer as its input and returns a comma-separated integer as a string.
separate_comma(1000) # => "1,000"
separate_comma(1000000) # => "1,000,000"
separate_comma(0) # => "0"
separate_comma(100) # => "100"