[solved] – Question 79939
Consider the following function f.
def f(m):
if m==0:
return(0)
else:
return(m+f(m-1))
Which one of the following is correct?
1)The function always terminates with f(n)=n(n+1)/2
2)The function always terminates with f(n)=factorial of n
3)The function terminates for non-negative n with f(n)=n(n+1)/2
4)The function terminates for non-negative n with f(n)=factorial of n
Expert Answer
[solved] – Question 79940
Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.
Here are some examples of how your function should work.
>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3
Expert Answer
[solved] – Question 79941
Write a function matched(s) that takes as input a string s and checks if the brackets “(” and “)” in s are matched: that is, every “(” has a matching “)” after it and every “)” has a matching “(” before it. Your function should ignore all other symbols that appear in s. Your function should return True if s has matched brackets and False if it does not.
Here are some examples to show how your function should work.
>>> matched(“zb%78”)
True
>>> matched(“(7)(a”)
False
>>> matched(“a)*(?”)
False
>>> matched(“((jkl)78(A)&l(8(dd(FJI:),):)?)”)
True
Expert Answer
[solved] – Question 79942
One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)
x = [1,”abcd”,2,”efgh”,[3,4]] # Statement 1
y = x[0:50] # Statement 2
z = y # Statement 3
w = x # Statement 4
x[1] = x[1] + ‘d’ # Statement 5
x[1][1] = ‘y’ # Statement 6
y[2] = 4 # Statement 7
z[0] = 0 # Statement 8
w[4][0] = 1000 # Statement 9
a = (x[4][1] == 4) # Statement 10
Expert Answer
[solved] – Question 79943
2.5 points
2.5 points
Consider the following lines of Python code.
x = [13,4,17,1000]
w = x[1:]
u = x[1:]
y = x
u[0] = 50
y[1] = 40
Which of the following is correct?
1) x[1] == 40, y[1] == 40, w[0] == 50, u[0] == 50
2) x[1] == 4, y[1] == 40, w[0] == 4, u[0] == 50
3) x[1] == 50, y[1] == 50, w[0] == 50, u[0] == 50
4) x[1] == 40, y[1] == 40, w[0] == 4, u[0] == 50
Expert Answer
[solved] – Question 79944
What is the value of endmsg after executing the following lines?
startmsg = “hello”
endmsg = “”
for i in range(0,len(startmsg)):
endmsg = startmsg[i] + endmsg
Expert Answer
[solved] – Question 79945
What is the value of mylist after the following lines are executed?
def mystery(l):
l = l + l
return()
mylist = [31,24,75]
mystery(mylist)
Expert Answer
[solved] – Question 79981
What is a Login Page javascript program that includes the following fields:
1. Input field for username
2. Input field for password
3. Background and picture
4. Title or heading
5. Validation code that will check that the user enters the correct username and password.
6. Instruction to the user
?
Expert Answer
[solved] – Question 79990
What is the value of h(231,8) for the function below?
def h(m,n):
ans = 0
while (m >= n):
(ans,m) = (ans+1,m-n)
return(ans)
Expert Answer
[solved] – Question 79999
What is the value of h(231,8) for the function below?
def h(m,n):
ans = 0
while (m >= n):
(ans,m) = (ans+1,m-n)
return(ans)
Expert Answer

