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

80.2K

Verified Solution

Question

Programming

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

Answer & Explanation Solved by verified expert
4.0 Ratings (440 Votes)
Please ask 1 question at a time    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students