Question

You are learning a new language, and are having a competition to see how many unique...

You are learning a new language, and are having a competition to see how many unique words you know in it to test your vocabulary learning.

Write a program where you can enter one word at a time, and be told how many unique words you have entered. You should not count duplicates. The program should stop asking for more words when you enter a blank line.

For example:

 
Word: Chat
Word: Chien
Word: Chat
Word: Escargot
Word: 
You know 3 unique word(s)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

# using set() to avoid duplication

words=set()
  
while(True):
   word=input("Word: ")
   if(word==""):
       break;
   words.add(word)

uniqueWords=str(len(words))

print("You know", uniqueWords,"unique word(s)")

Program Screenshot:

CountUnique Words - Notepad File Edit Format View Help #using set() to avoid duplication words=set() while(True): word=input(

Output:

Windows PowerShell - OX PS C:\Users\user\Desktop> py CountUniquewords.py Word: Chat Word: Chien Word: Chat Word: Excargot Wor

Add a comment
Know the answer?
Add Answer to:
You are learning a new language, and are having a competition to see how many unique...
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
  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

  • I need help with my Java code. A user enters a sentence and the program will...

    I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...

  • I am unsure on how to do this (java language) The program you must write needs...

    I am unsure on how to do this (java language) The program you must write needs to perform the following. 1. Read from stdin(System.in), up to 100 whitespace separated words, and store them in a data structure of your choice. 2. Calculate the average word length. 3. Print each word which is greater than the average length, in the reverse order thatthey were read in. 4. Print "Average: "followed the average word length to two decimal places. 5. If no...

  • Please write the code in assembly language which can run in HLA. Thank you very much!!...

    Please write the code in assembly language which can run in HLA. Thank you very much!! -So we need to write the code in assembly language in Notepad++, end with .hla and run it in CMD. - This project is about writing a program to read numbers, counts the items read, calculates the total, the maximum and minimum of the numbers. -The program stops when a 0 is entered. Zero will not be part of the data. -work with integers,...

  • JAVA LANGUAGE For this lab you are required to fulfill all requirements exactly as described in...

    JAVA LANGUAGE For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more. Question: Today you are to write a Java program that will prompt for and read 2 words of equal length entered by the user, and create a new word which contains the last letter of the 1st word, the last letter of the 2nd word, followed by the second to last character of the 1st word, followed...

  • A competition takes place for the development of a new functionality that will be added on...

    A competition takes place for the development of a new functionality that will be added on the NBA daily stats. This new functionality will show the player with the maximum ratio of points per minute. Develop a program in C++ that prompts the user to enter data for a number of NBA players and then outputs the player(s) with the maximum ratio of points per minute. You can store the players entered by the user in an array of structs...

  • How to play Bulls and Cows between you (the host) and your computer (the player) When...

    How to play Bulls and Cows between you (the host) and your computer (the player) When completed, your program allows you to host the game (i.e., you create a secret word and score every guess) and it makes guesses until it wins. During the development or testing of your program, you may set a condition (e.g., the total count of guesses is already 10) to allow your program to request to reveal the secret word and quit the game. In...

  • I am having trouble figuring out what should go in the place of "number" to make...

    I am having trouble figuring out what should go in the place of "number" to make the loop stop as soon as they enter the value they put in for the "count" input. I am also having trouble nesting a do while loop into the original while loop (if that is even what I am supposed to do to get the program to keep going if the user wants to enter more numbers???) I have inserted the question below, as...

  • How many unique peaks would you expect to see in a 13C-NMR spectrum of molecule A,...

    How many unique peaks would you expect to see in a 13C-NMR spectrum of molecule A, given that each unique chemical environment should give rise to a unique peak? Molecule A Molecule B Molecule C HN Molecule D Molecule E Molecule F он Molecule G Molecule H Molecule I Molecule J Molecule K Molecule L HN Molecule M Molecule N Molecule o

  • Description: Overview: You will write a program (says wordcountfreq.c) to find out the number of words and how many times each word appears (i.e., the frequency) in multiple text files. Specifically,...

    Description: Overview: You will write a program (says wordcountfreq.c) to find out the number of words and how many times each word appears (i.e., the frequency) in multiple text files. Specifically, the program will first determine the number of files to be processed. Then, the program will createmultiple threads where each thread is responsible for one file to count the number of words appeared in the file and report the number of time each word appears in a global linked-list....

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