Question

In: Computer Science

PYTHON Define a function named variousChanges(...) which receives one string (origst) (with letters, digits or special...

PYTHON Define a function named variousChanges(...) which receives one string (origst) (with letters, digits or special characters), possibly empty, and returns a new string containing the following.

a) in those positions where the original string has an even digit, the corresponding character in the new (returned) string should have the string digit '0'
b) in those positions where the original string has a vowel letter (upper or lower case), the new (returned) string should have the letter 'V'. Note that the vowels are : 'a', 'e', 'i', 'o', 'u'
c) any other position in the new (returned) string should have a star ('*')

AND
d) at the end of the new string, there should be a number attached, which is the number of upper case letters in the original string.

For example,
variousChanges("A>e>X34S") should return the string "V*V***0*3" because:

'A' (in position 0) and 'e' (in position 2) are vowels --- so the new string has a 'V' in those positions
'4' (in position 6) is an even digit --- so the new string has a '0' in that position
all other positions have '*' in the new string
'A' , 'X' and 'S' are three upper case letters in the original string --- so the new string has a 3 at the end

Solutions

Expert Solution

hello,

providing you the function for your requirement:-(i will also provide the snapshot of the function to reduce indentation error)

code starts here:-

def variousChanges(origst):
    count=0
    x=''
    for i in origst:
        if(i.isdigit()):
            if(int(i)%2==0):
                x=x+'0'
            else:
                x=x+'*'
        elif i in 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM':
            if(i.isupper()):
                count=count+1
            if i in 'aeiouAEIOU':
                x=x+'V'
            else:
                x=x+'*'
        else:
            x=x+'*'
    x=x+str(count)
    return x

code ends here:-

snapshot of code:-

sample output for test run as :-

.

output:-

i hope i was able to solve your problem to a greater extent, please feel free to comment your queries, Please consider my efforts and upvote my solution.

Thanku:)


Related Solutions

In Python Create a function called ????. The function receives a "string" that represents a year...
In Python Create a function called ????. The function receives a "string" that represents a year (the variable with this "String" will be called uve) and a list containing "strings" representing bank accounts (call this list ????). • Each account is represented by 8 characters. The format of each account number is "** - ** - **", where the asterisks are replaced by numeric characters. o For example, “59-04-23”. • The two central characters of the "string" of each account...
Python program. Write a function called cleanLowerWord that receives a string as a parameter and returns...
Python program. Write a function called cleanLowerWord that receives a string as a parameter and returns a new string that is a copy of the parameter where all the lowercase letters are kept as such, uppercase letters are converted to lowercase, and everything else is deleted. For example, the function call cleanLowerWord("Hello, User 15!") should return the string "hellouser". For this, you can start by copying the following functions discussed in class into your file: # Checks if ch is...
Python program.  from random import . Write a function called cleanLowerWord that receives a string as a...
Python program.  from random import . Write a function called cleanLowerWord that receives a string as a parameter and returns a new string that is a copy of the parameter where all the lowercase letters are kept as such, uppercase letters are converted to lowercase, and everything else is deleted. For example, the function call cleanLowerWord("Hello, User 15!") should return the string "hellouser". For this, you can start by copying the following functions discussed in class into your file: # Checks...
Python: Write a function that receives a one dimensional array of integers and returns a Python...
Python: Write a function that receives a one dimensional array of integers and returns a Python tuple with two values - minimum and maximum values in the input array. You may assume that the input array will contain only integers and will have at least one element. You do not need to check for those conditions. Restrictions: No built-in Python data structures are allowed (lists, dictionaries etc). OK to use a Python tuple to store and return the result. Below...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and...
C++ Please Define a function named "isAscending" that accepts a string as an input parameter and returns "true" if all the characters included in the string are ordered in ascending order of their ASCII codes or the input string is a null string, and returns "false" otherwise. For example, if the string "ABXab" is passed to the function, it returns "true" because the ASCII code of 'B' is greater than 'A', 'X' is greater than 'B', 'a' is greater than...
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min...
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min and max, from the program that invoked it. The function asks the user to enter a float number. Using a while loop it checks whether the number is valid (between min and max, inclusive). If not valid, the while loop uses this statement to prompt for a new number: num = float (input (" Enter a number that is at least :"+ str(min) +...
Creates a function called pick. The function receives a "string" representing one year (the variable with...
Creates a function called pick. The function receives a "string" representing one year (the variable with this "string" will be called uve) and a list containing "strings" representing bank accounts (call this bera list). <br> • Each account is represented by 8 characters. The format of each account number is "**-**-**", where asterisks are replaced by numeric characters. o For example, "59-04-23". • The two central characters of the "string" for each account represent the year the account was created....
Define a function digits_stars(...) which receives as input one digit (that is, an integer number greater...
Define a function digits_stars(...) which receives as input one digit (that is, an integer number greater or equal than 0 and less or equal than 9). The function should return a string. The string will have , alternating, a digit and a "*" symbol, starting with the digit 0, then a star, then the digit 1, then a star, and so on, alternating until reaching the input digit and one star symbol to end the string. As an example, the...
please solve by utilizing python Define a function named checkOut which takes two JSON strings, each...
please solve by utilizing python Define a function named checkOut which takes two JSON strings, each representing a dictionary. The first has the following structure, { "customer" : name , "cart" : [ item1, item2, ... ] } The second has the following structure, { item1 : price1, item2 : price2, ... } The function must return a JSON string representing the following dictionary: { "customer" : name, "amount_due" : x } where x is the sum of the prices...
python 3 please Define a function voweliest that takes as input a string and returns as...
python 3 please Define a function voweliest that takes as input a string and returns as output a tuple where the string that has the most vowels in it is the first element and the second is the number of vowels in that string. Note: don't worry about ties or capital letters Hint: consider defining and using a separate function that counts the number of vowels in a given string
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT