- Required Questions import math def...

This preview shows page 1 - 3 out of 3 pages.

###################### # Required Questions # ###################### import math def sine(x): """Returns the value of sine(x), where x is a value in radians. Use 0.0001 as a threshold. >>> from math import pi >>> sine(pi) #Notice how the value is very small but not quite 0. -1.482085565385205e-09 >>> sine(pi/2) 1.0 >>> sine((7 * pi)/2) -1.0 >>> sine(1.5) 0.9974949867067586 """ return 3*math.sin(x/3)-4*math.sin(x/3)**3 def is_palindrome(lst): """ Returns True if the list is a palindrome. A palindrome is a list that reads the same forwards as backwards >>> is_palindrome([1, 2, 3, 4, 5]) False >>> is_palindrome(["p", "a", "l", "i", "n", "d", "r", "o", "m", "e"]) False >>> is_palindrome([True, False, True]) True >>> is_palindrome([]) True >>> is_palindrome(["a", "v", "a"]) True >>> is_palindrome(["racecar", "racecar"]) True >>> is_palindrome(["r", "a", "c", "e", "c", "a", "r"]) True """ for i in range(len(lst)//2): if lst[i] != lst[-1-i]: return False return True def ab_plus_c(a, b, c): """Computes a * b + c. >>> ab_plus_c(2, 4, 3) # 2 * 4 + 3 11 >>> ab_plus_c(0, 3, 2) # 0 * 3 + 2 2 >>> ab_plus_c(3, 0, 2) # 3 * 0 + 2 2 """ if b == 0: return c else: return a + ab_plus_c(a, b-1, c)
Image of page 1

Subscribe to view the full document.

def gcd(a, b): """Returns the greatest common divisor of a and b.
Image of page 2
Image of page 3
  • Fall '18
  • The Return, Greatest common divisor, Divisor

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern