[solved] – Question 80439

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 8045

what does %d , %f and &a mean in C (not C#)

Expert Answer


[solved] – Question 80492

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 80493

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 80499

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 805

I am writing a program that finds both the largest and smallest of several integers. These are the integers: 6 20 30 40 50 60 70. Assume that the first integer read specifies the number of values remaining to be entered and that the first number is not one of the integers to compare. Your program should read only one value per input statement. Where do I start?

Expert Answer


[solved] – Question 80523

def mystery(l):
if l == []:
return (l)
else:
return (l[-1:] + mystery(l[:-1]))
What does mystery([13,23,17,81,15]) return?

Expert Answer


[solved] – Question 80561

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 80652

What is the value of pairs after the following assignment?
pairs = [ (x,y) for x in range(4) for y in range(3) if (x+y)%3 == 0 ]

Expert Answer


[solved] – Question 80688

Write a program that implements the student class. The student objects will have name, age, average and town of residence. The program will create an array of at least 5 student class objects and offer the following options to the user.

1. print the information of a particular student as the user enters the student’s name

2.Print the names of all students that have an average greater than a value that the user entered

3.Print the name of all students for a specific town that the user indicates

Expert Answer