# [Tutor] Question regarding Python loops

Conner Crowe connerjoy1994 at hotmail.com
Thu Apr 10 04:04:10 CEST 2014

```To whom this may concern:

I am struggling on two questions:
Problem 2.
Suppose you are given a function leave(minute) which returns the number of students
that leave an exam during its mth minute. Write a function already_left(t) that
returns the number of students that left at or before minute t of the exam.

Example code:
# To simplify testing, you may wish to define a stand-in function for leave that
# behaves predictably
# Here's one possible stand-in:
def leave(minute):
if minute > 0:
return minute
return 0

Example usage:

Example output:
1
10

So far for this i have:
def leave(minute):
if minute > 0:
return minute
elif minute=0:
return 0
for i in range(0,t):
leave(i)

Problem 3.

returns the percent of the class that has left at or before minute t, assuming
the exam is l minutes long, and the entire class has left at or before minute l.
Return your result as a float between 0 and 1.

Example code:

def percent_left(t, l):

Example usage:
print percent_left(0, 4)
print percent_left(1, 4)
print percent_left(4, 4)
print percent_left(30, 50)

Example output:
0.0
0.1
1.0
0.364705882353
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140409/d3020935/attachment.html>
```