Vous êtes sur la page 1sur 2

APS106 - Lab #3

This lab will test your ability to define and call functions as well as to operate with strings and use various
string methods. Place appropriate comments in your program. Due: 11:59pm, Sunday, Feb. 4, 2018

QUESTION: Programming is prevalent among all engineering and science disciplines, as well as teaching. Here are
some useful functions when dealing with student records at a university. The starter code below provides an optional
testing block. When you are ready to test your functions, uncomment the testing block at the bottom of the starter
code, then comment it again when you are done testing and ready to submit to MarkUs. The test-cases at the end of
this manual will help you understand sample inputs and outputs.

TO DO: Download the file lab3.py, complete the functions inside according to their descriptions and
upload your version of lab3.py to MarkUs.

def max_number(s):
'''
(str) -> float

Given s, a string representation of a sequence of two floating


point numbers formatted as 'number1,number2', e.g., '1.0,12.0',
return the largest number in s as a floating point number.

>>> max_number('10.0,20.0')
20
'''

def first_name_last_name_to_email(name):
'''
(str) -> str

Given a string name with the format "first_name last_name", return a string
"first_name.last_name@mail.utoronto.ca", where all letters are lowercase.

>>> first_name_last_name_to_email('Hana Hastings')


'hana.hastings@mail.utoronto.ca'
'''

def student_midterm_mark(name, test_marks):


'''
(str, str) -> str

Given a student's name, with the format "first_name last_name", test


marks formatted as 'floating_point_number1,floating_point_number2', return
a string "<email_address,midterm_mark>", where email_address has the format
first_name.last_name@mail.utoronto.ca and the midterm_mark is the largest number
in the sequence test_marks. All letters in email_address are lowercase.

>>> student_midterm_mark("Hanna Hastings",'10.0,20.0')


'<hanna.hastings@mail.utoronto.ca,20.0>'
'''
Sample Inputs and outputs:
(Running the first line should give you the result on the second line.)

max_number('10.0,20.0',)
20.0

max_number('45.0,67.8',)
67.8

max_number('-5,-6.7',)
-5.0

first_name_last_name_to_email('Hana Hastings',)
hana.hastings@mail.utoronto.ca

first_name_last_name_to_email('Chang Chen',)
chang.chen@mail.utoronto.ca

first_name_last_name_to_email('Dan Dorval',)
dan.dorval@mail.utoronto.ca
student_midterm_mark('Hanna Hastings', '10.0,20.0')
<hanna.hastings@mail.utoronto.ca,20.0>

student_midterm_mark('Dan Silvester', '20.0,25.0')


<dan.silvester@mail.utoronto.ca,25.0>

student_midterm_mark('Chang Chen', '45.0,67.8')


<chang.chen@mail.utoronto.ca,67.8>

student_midterm_mark('Dan Dorval', '-5,-6.7')


<dan.dorval@mail.utoronto.ca,-5.0>

Vous aimerez peut-être aussi