Python Homework Help: Are Each of The Following True or False
Python Homework Help: Are Each of The Following True or False
For any Assignment related queries, Call us at : - +1 678 648 4277
You can mail us at :- [email protected] or
reach us at :- https://www.pythonhomeworkhelp.com/
T = (0.1, 0.1)
x = 0.0
for i in range(len(T)): for j in T:
x += i + j print x
print i
0.1
0.2
1.3
2.4
1
3) What does the following code
print?
def f(s):
if len(s) <= 1:
return s #Note double
return f(f(s[1:])) recursion
+ s[0]f('mat')
print
print f('math')
at
m
hat
m
4) Implement the body of the function specified in
the box.
def findAll(wordList, lStr):
"""assumes: wordList is a list of words in
lowercase. lStr is a str of lowercase
letters.
No letter occurs in lStr more than once
returns: a list of all the words in wordList that
contain each of the letters in lStr exactly
once and no letters not in lStr."""
def findAll(wordList,
letters): result = []
letters = sorted(letters)
for w in
wordList:
w =
sorted(w)
if w == letters:
result.append(
5) The following
w) return resultcode does not meet its specification. Correct it.
v1 = v1[:]
v2 = v2[:]
6)Consider the following code:
def logBase2(n):
"""assumes that n is a positive int
returns a float that approximates the log base 2 of
n""" import math
return math.log(n, 2)
def f(n):
"""assumes n is an int""" if n < 1:
return
curDigit = int(logBase2(n)) ans = 'n =
'
while curDigit >= 0:
if n%(2**curDigit) < n: ans = ans +
'1'
n = n - 2**curDigit
else:
ans = ans + '0' curDigit -= 1
return ans
None n = 1
n = 10
2)Under the assumption that logBase2 is O(n), what is the order (use
big Oh notation) of f?
O(n)
8) Next to each item in the left column write the letter labeling the item in the
right column that best matches the item in the left column. No item in the
right column should be used more than once.
d) approximation
f) exponential
9.Do you think that the lectures are too slow paced, too fast paced, about
right?
10.Do you think that the problem sets are too short, too long, about right?