Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Required questions for lab 1"""
- ## Boolean Operators ##
- # Q4
- def both_positive(x, y):
- """Returns True if both x and y are positive.
- >>> both_positive(-1, 1)
- False
- >>> both_positive(1, 1)
- True
- """
- "*** YOUR CODE HERE ***"
- return x and y > 0
- ## while Loops ##
- # Q9
- def factors(n):
- """Prints out all of the numbers that divide `n` evenly.
- >>> factors(20)
- 20
- 10
- 5
- 4
- 2
- 1
- """
- "*** YOUR CODE HERE ***"
- # Q10
- def fib(n):
- """Returns the nth Fibonacci number.
- >>> fib(0)
- 0
- >>> fib(1)
- 1
- >>> fib(2)
- 1
- >>> fib(3)
- 2
- >>> fib(4)
- 3
- >>> fib(5)
- 5
- >>> fib(6)
- 8
- >>> fib(100)
- 354224848179261915075
- """
- "*** YOUR CODE HERE ***"
Advertisement
Add Comment
Please, Sign In to add comment