Question

Implement a program that requests from the user a list of words (i.e., strings) and then...

Implement a program that requests from the user a list of words (i.e., strings) and then prints on the screen, one per line, all four-letter strings in the list.

>>> Enter word list: ['stop', 'desktop', 'top', 'post']

stop

post

An acronym is a word formed by taking the first letters of the words in a phrase and then making a word from them. For example, RAM is an acronym for random access memory.

Write a function acronym() that takes a phrase (i.e., a string) as input and then returns the acronym for that phrase.

Note: The acronym should be all uppercase, even if the words in the phrase are not capitalized.

>>> acronym('Random access memory')

'RAM'

>>> acronym('central processing unit')

'CPU'

  1. Define a class called Animal that abstracts animals and supports three methods:
  • setSpecies(species): Sets the species of the animal object to species.
  • setLanguage(language): Sets the language of the animal object to language.
  • speak(): Prints a message from the animal as shown below.

The class must support supports a two, one, or no input argument constructor.

Then define Bird as a subclass of Animal and change the behavior of method speak() in class Bird.

>>> snoopy = Animal('dog', 'bark')

>>> snoopy.speak()

I am a dog and I bark.

>>> tweety = Animal('canary')

>>> tweety.speak()

I am a canary and I make sounds.

>>> animal = Animal()

>>> animal.speak()

I am a animal and I make sounds.

>>> daffy = Bird()

>>> daffy.speak()

quack! quack! quack!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

strnew =input("Enter word list:")
list = strnew.split (",")
for i in list:
if(len(i)==4):
print(i)
  

Expected output:

def acronym(phrase):
listwrds=phrase.split(' ');
stri="";
for i in listwrds:
stri+=(i.upper())[0];
  
return stri;
  
print(acronym('Random access memory'))
print(acronym('Central processing unit'))

Expected output:

class Animal:

def __init__(self,species="animal",language="make sounds"):
self.__species=species;
self.__language=language;
  
  
  
  
def setSpecies(self,species):
self.__species=species;
  
def setLanguage(self,language):
self.__language=language;
  
def speak(self):
print('I am a '+self.__species+" and I "+self.__language);
  
class Bird(Animal):
  
def speak(self):
print("quack! quack! quack!");
  
snoopy = Animal('dog', 'bark');
snoopy.speak();
tweety = Animal('canary');
tweety.speak();
animal = Animal();
animal.speak();
daffy = Bird();
daffy.speak();

Expected output:

Add a comment
Know the answer?
Add Answer to:
Implement a program that requests from the user a list of words (i.e., strings) and then...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Implement a program that requests from the user a list of words (i.e., strings) and...

    Python Implement a program that requests from the user a list of words (i.e., strings) and then prints on the screen, one per line, all four-letter strings in the list. >>> Enter word list: ['stop', 'desktop', 'top', 'post'] stop post

  • I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • I am currently facing a problem with my python program which i have pasted below where...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • 1. Write a Java program to count all words in a string. User inputs a string...

    1. Write a Java program to count all words in a string. User inputs a string sentence and your program should count the number of words in that string. Test Data: Input the string: The quick brown fox jumps over the lazy dog. Expected Output: Number of words in the string: 9 2. Write a class called ATMTransaction. This class has a variable balance and account number. It has three methods, checkBalance, deposit and withdraws along with constructors getters and...

  • Write a French/English dictionary lookup program. Read a list of pairs of English and French words...

    Write a French/English dictionary lookup program. Read a list of pairs of English and French words from a file specified by the user. English/French words should be exact matches (don't try to find partial matches). Use the supplied EnglishFrenchDictionary.java class as your main class. Fill in the missing code in the DictionaryTable.java class to read the input file and perform the searches. Add code to the DictionaryTable read() method to: read pairs of lines (English word is on the first...

  • Hi there! I need to compare two essay into 1 essay, and make it interesting and...

    Hi there! I need to compare two essay into 1 essay, and make it interesting and choose couple topics which im going to talk about in my essay FIRST ESSAY “Teaching New Worlds/New Words” bell hooks Like desire, language disrupts, refuses to be contained within boundaries. It speaks itself against our will, in words and thoughts that intrude, even violate the most private spaces of mind and body. It was in my first year of college that I read Adrienne...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT