Question

In: Computer Science

def main(): phrase = input('Enter a phrase: ') # take a phrase from user acronym =...

def main():
phrase = input('Enter a phrase: ') # take a phrase from user
acronym = '' # initialize empty acronym
for word in phrase.split(): # for each word in phrase
acronym += word[0].upper() # add uppercase version of first letter to acronym
print('Acronym for ' + phrase + ' is ' + acronym) # print results

main()

The program should then open the input file, treat whatever is on each line as a phrase and make its acronym using the function you wrote. It should print the acronyms, one per line to the output file. Assume that the input file will be already present in your default Python folder. The output file will be expected to get saved to the same folder. See below for an example input file input.txt and its corresponding output file output.txt that the program should generate.

Input: personal computer

Output:PC

Solutions

Expert Solution


Related Solutions

5. Take user input and give corresponding output. User will enter a sentence. The program will...
5. Take user input and give corresponding output. User will enter a sentence. The program will output the word that appears most frequently in this sentence. If there are multiple words with same frequency, output the first of these words. Please enter a sentence: I like batman because batman saved the city many times. The most frequent word is: batman The frequency is: 2 PYTHON
Input a phrase from the keyboard. If the last letter in the phrase is "a" or...
Input a phrase from the keyboard. If the last letter in the phrase is "a" or "e" (uppercase or lowercase) then output the last letter 3 times. ELSE If the first letter in the phrase is either "i", "o", or "u" (uppercase or lowercase) then output the length of the phrase In all other cases print "no vowel" Code language is java
def main():     print('This program determines whether you have hypertension.')     systolic_pressure = float(input('Enter your systolic...
def main():     print('This program determines whether you have hypertension.')     systolic_pressure = float(input('Enter your systolic pressure: '))     diastolic_pressure = float(input('Enter your diastolic pressure: '))     # insert statement here to call the hypertension_tester function def hypertension_tester(dp, sp):     if sp >= 140 or dp >= 90:         print('You have hypertension')     else:         print('You do not have hypertension') main() A person has hypertension if systolic pressure is 140 or above or diastolic pressure is 90 or above. Which of the...
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
def main():     # keeping asking user for a word or name until user enters 0    ...
def main():     # keeping asking user for a word or name until user enters 0     while True:         word = input('Enter a word/name to convert (enter 0 to quit): ').upper()       if word == '0': break         print(convert_to_soundex(word)) Whenever i try to run the program it tells me unintend doesn't match any outer identation level !!!!
JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
User is asked to enter a series of numbers. That input will stop when user enters...
User is asked to enter a series of numbers. That input will stop when user enters -9999. Find a maximum number from that series and a minimum number from that series. Output the location of Maximum number and minimum number.  Write a C++ program that asks the user to repeatedly input positive numbers until   -1 is pressed. Your program should print the second largest number and the count of even and odd numbers.  Write a C++ program that asks...
Write below in Python Get user name from keyboard using input() function (Example username = input("Enter...
Write below in Python Get user name from keyboard using input() function (Example username = input("Enter username:") A: What is your name? B: My name is XXXX. B: What is yours? A: My name is XXXX. A: Nice to meet you. B: Nice to meet you, too. Use print statement and use input() function
JAVA Input a phrase from the keyboard, if the phrase contains "red" or "RED" print out...
JAVA Input a phrase from the keyboard, if the phrase contains "red" or "RED" print out "red" . if the phrase contains "blue" or "BLUE" output "blue" In all other cases print "No Color" For example: If the input was "Violets are BLUE" your output should be "blue" If the input was "Singing the blues" output "blue" If the input was "I have a pure bred puppy" your output should be "red" If the input was "Today is Monday" output...
Input a phrase from the keyboard and output whether or not it is a palindrome. For...
Input a phrase from the keyboard and output whether or not it is a palindrome. For example: 1. If the input is Madam I'm Adam Your output should be "Madam, I'm Adam" is a palindrome 2. If your input is Going to the movies? Your output should be "Going to the movies?" is not a palindrome Note the quotes in the output line. Code language java using JGrasp
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT