Question

Solve it in Python 4. An alternade is a word in which its letters, taken alternatively...

Solve it in Python

4. An alternade is a word in which its letters, taken alternatively in a strict sequence, and used in the same order as the original word, make up at least two other words. All letters must be used, but the smaller words are not necessarily of the same length. For example, a word with seven letters where every second letter is used will produce a four-letter word and a three-letter word. Here are two examples:

"board": makes "bad" and "or".

Write a function, alternade, that accepts as an argument the file name for the dictionary and then goes through each word in the list and tries to make two smaller words using every second letter. The smaller words must also be members of the list. Print the words to the screen in the above fashion.

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

I have written the code using PYTHON PROGRAMMING LANGUAGE.

INPUT :

board
alternade
word
letters
through
smaller
goes
function
examples
original
length

OUTPUT:

CODE:

#function definition for Alternade

def Alternade(filename):

#content of file , all words are in list now

wordslist = open("input.txt").readlines()

print(" ")#To print on console

#Accessing each word from wordslist

for i in range(len(wordslist)):

wordslist[i] = wordslist[i][:-1]#To remove enter last in each word

#to print the result on console

print("""+wordslist[i]+"": makes ""+wordslist[i][0::2]+"" and ""+wordslist[i][1::2]+""" )

if(__name__ == "__main__"):

Alternade("input.txt")#Calling Alternade

Thanks..

Add a comment
Know the answer?
Add Answer to:
Solve it in Python 4. An alternade is a word in which its letters, taken alternatively...
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
  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

  • In Python, having trouble writing this function. Define a function named makeDictionary with two parameters. The...

    In Python, having trouble writing this function. Define a function named makeDictionary with two parameters. The first argument passed the function must be a list of strings to be used as keys, while the second is a list of the same length containing values (of some type). This function must return a dictionary consisting of the keys paired with the corresponding values. Help would be appreciated

  • Python The Python "<" and ">" comparison operators can be used to compare which string variable...

    Python The Python "<" and ">" comparison operators can be used to compare which string variable has a greater value based on comparing the ASCII codes of the characters in each string, one by one. To take some examples: "tets" > "test" returns True because the third letter of the first string, "t", has a greater value than the third letter of the second string, "s". "testa" > "test" returns True because—while the first four letters in both words are...

  • In python Count the frequency of each word in a text file. Let the user choose...

    In python Count the frequency of each word in a text file. Let the user choose a filename to read. 1. The program will count the frequency with which each word appears in the text. 2. Words which are the spelled the same but differ by case will be combined. 3. Punctuation should be removed 4. If the file does not exist, use a ‘try-execption’ block to handle the error 5. Output will list the words alphabetically, with the word...

  • Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make...

    Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make a word. This type of arrangement is generally referred to as an anagram, it's known as a permutation in mathematics. This assignment will give you some experience thinking about and writing recursive functions. Write a C++ program that searches for ``anagrams'' in a dictionary. An anagram is a word obtained by scrambling the letters of some string. For example, the...

  • Please write the following code as simple as possible in python: You will need to define...

    Please write the following code as simple as possible in python: You will need to define a function with four arguments. Here is what I used: > def find_matches(file1.txt, output1.txt, strings, value): file1.txt will contain a list of various strings. The program must copy from the first argument, and it should be written in the second argument (the second file, "output1.txt"). The third and fourth arguments will determine which specific strings will be copied over to the second file. For...

  • Ch 04: Mastery Assignment - Introduction to Probability 4. Scrabble SCRABBLE is a word game in...

    Ch 04: Mastery Assignment - Introduction to Probability 4. Scrabble SCRABBLE is a word game in which two to four players score points by forming words from individual lettered tiles on a game board marked with a 15 by 15 grd. The words are formed across and down in crossword puzzle fashion and must appear in a standard dictionary. There are 100 tiles in all, including 2 blank tiles that serve as wild cards and can take on the value...

  • PYTHON Hello can someone create the following functions? I'm not sure how to start on them....

    PYTHON Hello can someone create the following functions? I'm not sure how to start on them. makeDictionary Define a function named makeDictionary with two parameters. The first argument passed the function must be a list of strings to be used as keys, while the second is a list of the same length containing values (of some type). This function must return a dictionary consisting of the keys paired with the corresponding values. For example, makeDictionary(['apno','value'],['REP-12','450']) must return this dictionary: {'apno':...

  • Write a structured (procedural) Python program that solves the following spec: Soundex System Coding: Soundex is...

    Write a structured (procedural) Python program that solves the following spec: Soundex System Coding: Soundex is a system that encodes a word into a letter followed by three numbers that roughly describe how the word sounds. Therefore, similar sounding words have the same four-character code. Use the following set of (slightly modified #4) rules to create a translator from English words to Soundex Code: Retain the first letter of the word. For letters 2 …n, delete any/all occurrences of the...

  • I have 4 questions dont know can anyone help me with any of it? ii) Consider the 11 letter word MATHEMATICS a) How many distinct words can be formed by rearranging its letters? b) How many 4 letter wo...

    I have 4 questions dont know can anyone help me with any of it? ii) Consider the 11 letter word MATHEMATICS a) How many distinct words can be formed by rearranging its letters? b) How many 4 letter words can be formed using the letters in the word MATHEMATICS, using letters no more often than they appear in the word? ii) Consider the equation where xi, x2, 13, T4,5 and re are non-negative integers a) How many solutions are there...

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
ADVERTISEMENT