Question: 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) -

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 ') quotes.write('you can do, to keep in the same place. ') quotes.close() print(analyzer('alice.txt'))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!