Task 2

 avatar
PEGG
python
11 days ago
1.8 kB
4
Indexable
Never
## first requirement
def count_vowels(word):
    count =0
    for i in word:
        if i in ['a','A','e','E','O','o','I','i','u','U']:
            count+=1
    return count

print(count_vowels("ayyyooo"))


## second requirement
number = input("enter 5 numbers \n")

numbers = list(map(int, number.split()))

descending_order=sorted(numbers,reverse=True)
print(descending_order)
ascending_order=sorted(numbers)
print(ascending_order)

##third requirement

def count_substring (word):

    return word.count("iti")

print(count_substring("itinonnonitmnoniti"))

##fourth requirement

def remove_vowels(word):
    new_word=[]
    for i in word:
        if i not in ['a','A','e','E','O','o','I','i','u','U']:
         new_word.append(i)
    return new_word

word=input("enter a word to be cleaned from vowels: \n")
clean_word=''.join(remove_vowels(word))
print("the cleaned word : ",clean_word,"\n")

#fifth requirement

def replace_vowels(word):
    new_word=[]
    for i in word:
        if i not in ['a','A','e','E','O','o','I','i','u','U']:
         new_word.append(i)
        elif i in ['a','A','e','E','O','o','I','i','u','U']:
         new_word.append('*')
    return new_word

word=input("enter a word to be replace vowles in it: \n")
alternate_word=''.join(replace_vowels(word))
print("the replaced word : ",alternate_word,"\n")

##sixth requirement
number = input("enter any numbers you want to reverse their order \n")

numbers = list(map(int, number.split()))

print(numbers[::~0],"\n")

#seventh requirement
def count_constants(word):
    count =0
    for i in word:
        if i not in ['a','A','e','E','O','o','I','i','u','U']:
            count+=1
    return count

print(count_constants("ayyyooo"))
Leave a Comment