Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS ( 1 0 0 Pts ) ( a ) ( 1 0 Pts ) [ Task

WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS (100 Pts)
(a)(10 Pts)[Task-1] Define a function called repeat_letters that takes a string and a number n as two parameters and prints the string with every letter repeated n times.
Sample input/Output:
print(repeat_letters("medipol",3))
"mmmeeedddiiipppooolll"
(b)(10 Pts)[Task-2] Define a function called find_index which takes as argument a word and a letter. It will return the index of the second occurrence of the letter in the given word.
Sample input/Output:
print(find_index ("welcomehome","e"))
6
(c)(10 Pts)[Task-3] Define a function called list_unique that takes a string str as an input, checks all letters of the string, and constructs a list that contains the list of character that appear in str. This list should not contain any duplicates.
Sample input/Output:
print(listunique(ankara))
['a','n','k','r']
(d)(10 Pts)[Task-4] Write a function called ngrams_list that takes a string and a number n and return the n-grams of the this string as a list
Sample input/Output:
print(ngramslist(computer,2))
[co,om,mp,pu,ut,te,er]
2
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

The assessor will make a determination of the tax due.

Answered: 1 week ago

Question

Over the past

Answered: 1 week ago