Chapter 5

 

 

Section 5.2

 

51073

send_signal()

51143

print_todays_date()

51136

def printDottedLine():

    print(".....")

Section 5.5

 

51144

print_error_description(14)

51074
send_number(5)
51075
send_variable(x)
51076
send_two(15.955,133)
51077
send_object(John_Doe)
51145
print_larger(sales1, sales2)
51137
def printGrade(grade):
    print("Grade:", grade)

Section 5.7

 

51146

eurasia_sales = add(euro_sales,asia_sales)

51147

cube_volume = to_the_power_of(cube_side,3)

Section 5.8

 

51155
def twice(int):
    return int*2
51139
def square(x):
    return x**2
51156
def add(x,y):
    return x+y
51016
def typing_speed(w, t):
    return float(w) / t * 60
51105
def min(s1, s2):
    if s1 < s2: return s1
    else: return s2
51218
def max(arg1, arg2, arg3):
    max = arg1
    if arg2 > max: max = arg2
    if arg3 > max: max = arg3
    return max
51158
def power_to(arg1, arg2):
    if arg2 < 0:
        return 0
    else:
        return pow(arg1, arg2)
51008
def is_prime(n) :
    if n < 2 : return False
    i = 2
    while i < n :
        if n % i == 0 : return False
        i += 1
    return True
51009
i = 2
count = 0
total = 0
while (count < n) :
    if (is_prime(i)) :
        total += i
        count = count + 1
    i += 1
51011
i = 2
k = 0
sum = 0
while (sum + i <= n):
    if (is_prime(i)):
        sum += i
        k += 1
    i += 1
51140

def add(x, y):
    return x + y

51142
def oneMore(x):
    return x + 1
51151
def oneLess(x):
    return x - 1
51141
def powerTo(x, y):
    if y >= 0:
        return x**y
    else:
        return 0
51138
def hasRealSolution(a, b, c):
    if b**2 - 4*a*c < 0:
        return False
    else:
        return True
51152
def half(x):
    return int(x/2)
51153
def absoluteValue(x):
    if x < 0:
        x *= -1
    return x
51154
def signOf(x):
    if x>0:
        return 1
    elif x == 0:
        return 0
    else:
        return -1
51157
def isPositive(x):
    if x > 0:
        return True
    else:
        return False
51159
def isSenior(age):
    if age >= 65:
        return True
    else:
        return False
51164
def isEven(x):
    if x%2 == 0:
        eturn True
    else:
        return False
51174
def min(x, y):
    if x < y:
        return x
    else:
        return y
MPL Extra  
51148
max(population1,population2)
51149
max2(max2(population1,population2),max2(population3,population4))