## Module 01 Extra Practice

# Part 1 - Warm up questions

# Type the following assignment statements into WingIDE's interactive environment
#  and ensure you understand the values of x,y,z

x = 5 * (6 - 1) + 8
y = x * x
z = "CS" + "116"

# Suppose n is a two-digit positive integer. 
# Replace n with the value of a two digit natural number.
 
n = ...

# Replace ... in the assignment statement below to initialize
# ones_digit to be the ones digit of n (use mathematical expressions
# to figure this out), tens_digit to be the tens digit of n
# (again using mathematical expressions), and sum_digits to be
# the sum of the digits

ones_digit = ...
tens_digit = ...
sum_digits = ...

# Complete the Python function add_num_to_str(s, n) that consumes
# a string s, and a natural number n, and returns a new string containing
# all the characters in s followed by the digits of n. 
# Recall that you have to convert n to a string!
# For example, add_num_to_str("CS", 116) => "CS116"

# Add purpose, contract, and examples here

def add_num_to_str(s, n):
    # Add body of function here
    pass

# Add test cases here - use check.expect
   
    
# Before running the following code, determine what the values of g1 and g2
# should be after the code is run. Then, run the code to confirm the answers.

bonus = 3
max_grade = 100

def apply_bonus(grade):
    grade = min(grade + bonus, max_grade)
    return grade

g1 = 72
g2 = g1
g1 = apply_bonus(g2)


# Part 2 - Extra Practice

## Question 1
## http://www.albinoblacksheep.com/flash/mind
## Write a function mindreader, which consumes an 
## integer, num, between 10 and 99, and returns the value of
## num minus the sum of its digits.

def mindreader(num):
    pass

## Question 2
## The sum
## 1 + 2 + 3 + ... + n
## is given by n*(n+1)/2. 
## Write a Python function sum_to than consumes n and returns the 
## sum from 1 to n, using this above formula.

def sum_to(n):
    pass 

## Question 3
## This question involves writing Python functions related to the average of
## three integers x,y,z.
## (a) Write average(x,y,z) to return the floating point average of the values.

def average(x,y,z):
    pass

## (b) Write int_average(x,y,z) to return the integer average, using the built-in
##     function round.

def int_average(x,y,z):
    pass

## (c) Write variation(x,y,z) to return the sum of the deviations of x,y,z from the 
##     floating point average of x,y,z, i.e. the sum of |x-mean| + |y-mean} + |z-mean|
##     where mean is the floating point average from (a).

def variation(x,y,z):
    pass