Answer:
Here is the Python program:
#the method acronym that takes an argument phrase
def acronym(phrases):
acronym = "" #to store acronym of a phrase
#loop to split the input phrase and return its acronym in upper case letters
for phrase in phrases.split():
acronym = acronym + phrase[0].upper()
return acronym
#main function that takes input phrase from user and display its acronym
def main():
phrases = input("Enter a phrase: ")
print("The acronym for your phrase is ",acronym(phrases))
main()
Explanation:
First let me explain the method acronym. This method takes a parameter phrase to return its corresponding acronym. First the phrase is split using split() method which is used to return the list of words in a phrase. For loop is used that will keep splitting the words in the string (phrase) entered by the user.
In this statement: acronym = acronym + phrase[0].upper() the acronym is computed. phrase[0] means the first character of each word in the phrase which is found out by the split() method is converted to upper case by using upper() function and then stored in acronym variable. Each time the acronym is found and its first character is converted to upper case and added to the acronym variable.
Then the main() function prompts the user to enter a phrase and then calls the acronym function and passed that phrase as parameter to that function. Then the computed acronym for the phrase is printed on the screen.
.............. one second
Answer:
hello 안녕하세요
Explanation:
mate I tried to write here but it says it's too much writing that why I attached a pic
BTW did u like that☺☺
Save as is the command that you would use to save anything when using microsoft
Answer:
def typeHistogram(it,n):
d = dict()
for i in it:
n -=1
if n>=0:
if str(type(i).__name__) not in d.keys():
d.setdefault(type(i).__name__,1)
else:
d[str(type(i).__name__)] += 1
else:
break
return list(d.items())
it = iter([1,2,'a','b','c',4,5])
print(typeHistogram(it,7))
Explanation:
- Create a typeHistogram function that has 2 parameters namely "it" and "n" where "it" is an iterator used to represent a sequence of values of different types while "n" is the total number of elements in the sequence.
- Initialize an empty dictionary and loop through the iterator "it".
- Check if n is greater than 0 and current string is not present in the dictionary, then set default type as 1 otherwise increment by 1.
- At the end return the list of items.
- Finally initialize the iterator and display the histogram by calling the typeHistogram.