CSC148H1 Midterm: CSC148H1 Term Test 1 2013 Fall Solutions

41 views4 pages
25 Oct 2018
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

I have left out the documentation for function s(n). Work out what it produces, starting at the smallest n and working up. def s(n: int) -> tuple: """for you to figure out""" if n == 1: return (1, 1) else: return min([(2 * s(n - i)[0] + 2**i - 1, i) for i in range(1,n)]) Python"s str. join concatenates a list of strings, using the given separator string, and returns the new string, as follows: Complete the denition of nested_join(), which concatenates the strings in a nested list of strings, using the given separator string, and returns the result. def nested_join(s: str, l: list) -> str: """return join of nested list of strings l with separator string s. One two three four solution: return str. join(s, [nested_join(s, x) if isinstance(x, list) else x for x in l]) You are to implement functionallist, a subclass of built-in class list. Functionallist should have two new methods: functional_append(self: functionallist , o: object) -> functionallist :

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents