aString = 'Springsteen, Springsteen, oh, Springsteen!' aList = aString.split() bossCount = 0 for word in aList: if word == 'Springsteen': bossCount += 1 print(bossCount) a. 0 b. 1 c. 2 d. 3 e. None of the above
output:
a. 0
explanation:
as spli() is given without any delemeter so the string is splited as
"Springsteen,"
"Springsteen,"
"oh,"
"Springsteen!"
The search word is given "Springsteen" so not matched at all
So output will be be 0 which is the initial value of bossCount.
if search word is "Springsteen," then output is 2
aString = 'Springsteen, Springsteen, oh, Springsteen!' aList = aString.split() bossCount = 0 for word in aList:...
aList = [1, 'Mercy', 20, 'Cyber', 300]. a) Write a single line of Python statement to print the value 20 from aList. b) Write a single line of Python statement to print the character b from aList. c) Write a single line of Python statement to print erc from aList. d) Write a Python segment that print a sequence number starting from 1 followed by ")" and an element for each element of the list. Use a for loop and...
def selectionSortK(alist, k):
for i in range(0,len(alist) - 1):
min = i
for j in range(i + 1, len(alist)):
if alist[j] < alist[min]:
min = j
temp = alist[i]
alist[i] = alist[min]
alist[min] = temp
P3: Sanity Test: Is selectionSortK callable? ... ok
test_doNothing (__main__.TestProblem3)
P3: Does sorting the first k elements with k=0 do nothing? ...
ok
test_onePass (__main__.TestProblem3)
P3: Sorting a portion of a decreasing list ... FAIL
test_severalPasses (__main__.TestProblem3)
P3: Sorting a decreasing list in several stages...
What are the outputs for each question PYTHON Question 6 bools = [True, 0>-1, not not True, 2%2 == 0, True and False] index = 0 while bools[index]: index += 1 print(index) a) 0 b) 1 c) 2 d) 3 e) none of the above Question 7 for i in range(2): for j in range(1): print(i, j, end = " ") a) no output b) 0 0 1 0 2 0 c) 0 0 0 1 1 0 1 1...
What will be printed upon running following code: alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3]))alist = [3, 50, "Kity", [50, 52, "Rover"], [ ], 3.14, False, 'a'] print(len(alist[3])) 8 7 2 an error 3 Select the best reason why the code below returns True, False, False respectively? a = 256 b = 256 print(id(a) == id(b)) c = 5.1 d = 5.1 print(id(c) == id(d)) x = 257 y = 257 print(id(x) ==...
Write the formula for the compound composed of Al3+ and OH- a. Al3OH b. Al(OH)3 c. Al3(OH)2 d. AlOH e. none of above
What does the following code display? (Careful!) x = 0 word = 'hello' if word == 'Hello': x = x + 5 else: x = 17 print(x) A.0 B.5 C.17 D.22
41. Find O! A) 1 B) O C) -1 0 2 E) None of the Above 42. Find P2 A) 120 B) 10 C) 3 D) 20 E) None of the Above 43. Find.cz A) 120 B) 10 C) 3 D) 20 E) None of the Above 44. Find the missing probability. 0 2 1 3 X 4 p(x) 0.12 0.13 0.27 ? 0.09 A) 1 B) 1.61 C) 0.39 D) 0.43 E) None of the Above 45. Find 4!...
all required info in picture
14. Here is a 4x3 memory: Word 0 Word 1 Ward 2 Word 3 Outy Ounl Outy In, D Q D Q Word O Select Word 3 Solect Word 1 Word 2 Write Clock So S, FIGURE 3.32 4 x 3 Memory a. Draw a truth table with inputs S1 and SO and an output indicating which word would be selected. b. Let's say that the four words in memory are: 1 0 0 Show...
explain
21. Which of the following represent the enol form of the following molecule? OH OH cox cox B)11, CI DIVE) None of the above III IV 4)1 A) I B) II C) III D) IV E) None of the above
*Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...