Questions
EXPLAIN ANS PLEASE: PYTHON 1. s = 'abc' print(s[0:] + s[-2:2] + s[:1]) 2. def mirrorOnWheels(s):...

EXPLAIN ANS PLEASE:

PYTHON

1. s = 'abc'
print(s[0:] + s[-2:2] + s[:1])

2. def mirrorOnWheels(s):
prev = 0
for current in range(1, len(s) - 1):
prev = current - 1
next = current + 1
if s[prev] == s[next]:
break
else:
continue
return 0
return prev
s = 'Good decision!'
print(mirrorOnWheels(s))

3. mixture = {1:[1, 2, 0], 2:[2, 0, 1], 0:[0, 1, 2]}

print(mixture[2][2])

4. noOddHeroes = []
heroes = ['superman', 'batman', 'aquaman']
for hero in heroes:
if len(hero) % 2 == 0:
noOddHeroes.append(hero)
print(noOddHeroes)


5. candyOnStick = 'lolli lolli lolli lollipop lollipop'
wordList = candyOnStick.split('i')
d = {}
for word in wordList:
if word not in d:
d[word] = 1
else:
d[word] += 1
print(len(d))

6. def oldMcDonald(farm):
result = 0
for animal in farm:
if animal[0] in farm[animal]:
result += 1
return result
farm = {'cow':'moo', 'duck':'quack', 'cricket':'chirp'}
print(oldMcDonald(farm))

7. def analyzer(fileName):
inputFile = open(fileName)
line = inputFile.readline()
inputFile.close()
return line.count(',')
quotes = open('alice.txt', 'w')
quotes.write('Now, here, you see, it takes all the running\n')
quotes.write('you can do, to keep in the same place.\n')
quotes.close()
print(analyzer('alice.txt'))

In: Computer Science

Cognitive Psychology: Applying The Science of the Mind (4th Edition) Chapter 10 Discussion Question: What do...

Cognitive Psychology: Applying The Science of the Mind (4th Edition)
Chapter 10

Discussion Question:
What do you think is the most important factor in communicating through your writing? Think of the comments you get from professors, or the problems you seem to have in writing. Do they map onto any of the factors you've read about?

Here's an example of one of my classmate response....
I feel that with writing being such a common way of communicating it is important to be as proficient as possible. To be able to do so it truly helps to understand the processes involved. After understanding the processes, you can come to utilize them within your writing to communicate effectively. For example, the word skipping issue in reading is something that also affects my writing. Word skipping is one of the biggest problems I have in reading and writing. Like stated in the textbook, short words such as “an” and “the” are more likely to be skipped. When writing sometimes I will repeat short words without even realizing it. When proofreading my writing to uncover mistakes like that I will just skip right over them without even realizing it and the mistake remains in my writing. One of my English teachers advised me to read through my writing backwards because this would ensure that I read it word per word and would likely not skip over any words. This advice helped me with detecting repeated short words that I usually skipped over.

In: Psychology

location X

Define: EA = (X)+ is the effective address equal to the contents of location X, with X incremented by one word length after the effective address is calculated; is the effective address equal to the contents of location X, with X decremented by one word length before the effective address is calculated; is the effective address equal to the contents of location X, with X decremented by one word length after the effective address is calculated. Consider the following instructions, each in the format (Operation Source Operand, Destination Operand), with the result of the operation placed in the destination operand.
a. OP X, (X)
b. OP (X), (X)+
c. OP (X), (X)
d. OP (X), (X)
e. OP (X), (X)+
f. OP (X), (X)+
g. OP (X), (X)
Using X as the stack pointer, which of these instructions can pop the top two elements from the stack, perform the designated operation (e.g., ADD source to destination and store in destination), and push the result back on the stack? For each such instruction, does the stack grow toward memory location 0 or in the opposite direction?

 

In: Computer Science

Question 5 On 31 December 2018, Sela Plc acquired Lomo Plc which had a separately identified...

Question 5

On 31 December 2018, Sela Plc acquired Lomo Plc which had a separately identified brand, valued at £7,600,000. In addition to this, Sela Plc also estimated at the end of 2019 that their own internally generated brand is worth £12,000,000. A director has suggested that both figures should be recorded in the statement of financial position as intangible assets, as brands would strengthen their financial position. Sela Plc is currently working towards a target gearing ratio in order to secure external funds for expansion. Both brands described have an indefinite life. Requirement:

i) With reference to the above scenario, explain how these brands would be accounted for in the financial statements of Sela Plc for year ending 31 December 2019. (maximum word count 140 words)

ii) How does the recognition and accounting treatment of goodwill differ from that used for brands? Explain any three differences. (maximum word count 120 words)

iii) Explain any two justifications for reporting brands as assets. (maximum word count 40 words)

In: Accounting

c++ 9.39 LAB: Replacement words Write a program that replaces words in a sentence. The input...

c++

9.39 LAB: Replacement words

Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced.

Ex: If the input is:

3   automobile car   manufacturer maker   children kids
15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one.

then the output is:

The car maker recommends car seats for kids if the car doesn't already have one. 

You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one.

Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements.

Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function returns -1.
int FindWordInWordList(vector<string> wordList, string wordToFind)

In: Computer Science

Part 1 Understand the Problem and Class Design with UML The client needs a program to...

Part 1 Understand the Problem and Class Design with UML

  • The client needs a program to calculate the age of a tuna fish. The program must store the length of the fish in cm, and the weight of the fish in pounds. To calculate the estimated age of the fish in years multiply the length times the weight then divide by 10000. Design a class based on this word problem.
  • Testing values are 300 cm length, and 1111.12 pounds.

  • Using the word problem above, design a class with the needed fields, one default (no parameter) constructor, and needed methods. Document your design using a detailed UML Class diagram.
  • Note: The calculations used in this word problem are fictional.

Part 2 Write the Java code for the class

  • Follow your UML class diagram and code the class you designed.
  • Use Java coding conventions for identifiers: class, constructor, field, variable, and method names
  • Mark fields private, constructor and methods public.
  • Select and use appropriate data types for the fields as well as method parameters as needed.
  • Comment your code as requested and demonstrated in the course.

In: Computer Science

Problem 2.55. Consider the dihedral group D3 introduced in Problem 2.21. To give us a common...

Problem 2.55. Consider the dihedral group D3 introduced in Problem 2.21. To give us a common starting point, let’s assume the triangle and hole are positioned so that one of the tips of the triangle is pointed up. Let r be rotation by 120◦ in the clockwise direction and let s be the reflection in D3 that fixes the top of the triangle.

(a) Describe the action of r −1 on the triangle and express r −1 as a word using r only.

(b) Describe the action of s −1 on the triangle and express s −1 as a word using s only.
(c) Prove that D3 = hr, si by writing every element of D3 as a word in r or s.

(d) Is {r, s} a minimal generating set for D3 ?

(e) Explain why there is no single generating set for D3 consisting of a single element. This proves that D3 is not cyclic.

It is important to point out that the fact that {r, s} is a minimal generating set for D3 does not imply that D3 is not a cyclic group. There are examples of cyclic groups that have minimal generating sets consisting of more than one element (see Problem 2.70).

In: Advanced Math

Reflect on the section Planning and Executing Change Effectively, in Chapter 7 of the text. Summarize...

Reflect on the section Planning and Executing Change Effectively, in Chapter 7 of the text. Summarize the key steps in planning and executing change in a 500 word journal entry.

In: Economics

“Inflation is caused by tightness in labour markets, so policy should be oriented at inducing unemployment...

“Inflation is caused by tightness in labour markets, so policy should be oriented at
inducing unemployment to bring down wages.” Critically discuss.
Word Limit – 750

In: Economics

Define the word "dumping"as used by trade policy makers in the USA and how this definition...

Define the word "dumping"as used by trade policy makers in the USA and how this definition can be used to justify protectionism, and why this definition is harmful to international trade

In: Economics