Question

Write a Python program that outputs all possible strings formed by using the characters c ,...

Write a Python program that outputs all possible strings formed by using

the characters c , a , t , d , o , and g exactly once.

Please show screenshots and copy the code.

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

BECAUSE OF THE IDENTATION PROBLEM WHILE SUBMITTING THE CODE I'M ALSO GIVING THE SCREENSHOT OF THE CODE SO THAT YOU CAN REFER IT :

main.py 1 from itertools import permutations # import itertools 2 1st = [c, a,t,d, o, g] 3 1 = list(permutations

PYTHON CODE :

from itertools import permutations # import itertools
lst = ['c','a','t','d', 'o', 'g']
l = list(permutations(lst, len(lst))) # permutations will collect them
string = ""
for i in range(len(l)):
for j in range(0, 6):
string = string + l[i][j] # appending characters to form a string
print(string) # print the result
string = ""

OUTPUT :

catdog catdgo catodg catogd catgdo catgod cadtog cadtgo cadotg cadogt cadgto cadgot caotdg caotgd caodtg caodgt caogtd caogdt cagtdo cagtod cagdto cagdot cagotd cagodt ctadog ctadgo ctaodg ctaogd ctagdo ctagod ctdaog ctdago ctdoag ctdoga ctdgao ctdgoa ctoadg ctoagd ctodag ctodga ctogad ctogda ctgado ctgaod ctgdao ctgdoa ctgoad ctgoda cdatog cdatgo cdaotg cdaogt cdagto cdagot cdtaog cdtago cdtoag cdtoga cdtgao cdtgoa cdoatg cdoagt cdotag cdotga cdogat cdogta cdgato cdgaot cdgtao cdgtoa cdgoat cdgota coatdg coatgd coadtg coadgt coagtd coagdt cotadg cotagd cotdag cotdga cotgad cotgda codatg codagt codtag codtga codgat codgta cogatd cogadt cogtad cogtda cogdat cogdta cgatdo cgatod cgadto cgadot cgaotd cgaodt cgtado cgtaod cgtdao cgtdoa cgtoad cgtoda cgdato cgdaot cgdtao cgdtoa cgdoat cgdota cgoatd cgoadt cgotad cgotda cgodat cgodta actdog actdgo actodg actogd actgdo actgod acdtog acdtgo acdotg acdogt acdgto acdgot acotdg acotgd acodtg acodgt acogtd acogdt acgtdo acgtod acgdto acgdot acgotd acgodt atcdog atcdgo atcodg atcogd atcgdo atcgod atdcog atdcgo atdocg atdogc atdgco atdgoc atocdg atocgd atodcg atodgc atogcd atogdc atgcdo atgcod atgdco atgdoc atgocd atgodc adctog adctgo adcotg adcogt adcgto adcgot adtcog adtcgo adtocg adtogc adtgco adtgoc adoctg adocgt adotcg adotgc adogct adogtc adgcto adgcot adgtco adgtoc adgoct adgotc aoctdg aoctgd aocdtg aocdgt aocgtd aocgdt aotcdg aotcgd aotdcg aotdgc aotgcd aotgdc aodctg aodcgt aodtcg aodtgc aodgct aodgtc aogctd aogcdt aogtcd aogtdc aogdct aogdtc agctdo agctod agcdto agcdot agcotd agcodt agtcdo agtcod agtdco agtdoc agtocd agtodc agdcto agdcot agdtco agdtoc agdoct agdotc agoctd agocdt agotcd agotdc agodct agodtc tcadog tcadgo tcaodg tcaogd tcagdo tcagod tcdaog tcdago tcdoag tcdoga tcdgao tcdgoa tcoadg tcoagd tcodag tcodga tcogad tcogda tcgado tcgaod tcgdao tcgdoa tcgoad tcgoda tacdog tacdgo tacodg tacogd tacgdo tacgod tadcog tadcgo tadocg tadogc tadgco tadgoc taocdg taocgd taodcg taodgc taogcd taogdc tagcdo tagcod tagdco tagdoc tagocd tagodc tdcaog tdcago tdcoag tdcoga tdcgao tdcgoa tdacog tdacgo tdaocg tdaogc tdagco tdagoc tdocag tdocga tdoacg tdoagc tdogca tdogac tdgcao tdgcoa tdgaco tdgaoc tdgoca tdgoac tocadg tocagd tocdag tocdga tocgad tocgda toacdg toacgd toadcg toadgc toagcd toagdc todcag todcga todacg todagc todgca todgac togcad togcda togacd togadc togdca togdac tgcado tgcaod tgcdao tgcdoa tgcoad tgcoda tgacdo tgacod tgadco tgadoc tgaocd tgaodc tgdcao tgdcoa tgdaco tgdaoc tgdoca tgdoac tgocad tgocda tgoacd tgoadc tgodca tgodac dcatog dcatgo dcaotg dcaogt dcagto dcagot dctaog dctago dctoag dctoga dctgao dctgoa dcoatg dcoagt dcotag dcotga dcogat dcogta dcgato dcgaot dcgtao dcgtoa dcgoat dcgota dactog dactgo dacotg dacogt dacgto dacgot datcog datcgo datocg datogc datgco datgoc daoctg daocgt daotcg daotgc daogct daogtc dagcto dagcot dagtco dagtoc dagoct dagotc dtcaog dtcago dtcoag dtcoga dtcgao dtcgoa dtacog dtacgo dtaocg dtaogc dtagco dtagoc dtocag dtocga dtoacg dtoagc dtogca dtogac dtgcao dtgcoa dtgaco dtgaoc dtgoca dtgoac docatg docagt doctag doctga docgat docgta doactg doacgt doatcg doatgc doagct doagtc dotcag dotcga dotacg dotagc dotgca dotgac dogcat dogcta dogact dogatc dogtca dogtac dgcato dgcaot dgctao dgctoa dgcoat dgcota dgacto dgacot dgatco dgatoc dgaoct dgaotc dgtcao dgtcoa dgtaco dgtaoc dgtoca dgtoac dgocat dgocta dgoact dgoatc dgotca dgotac ocatdg ocatgd ocadtg ocadgt ocagtd ocagdt octadg octagd octdag octdga octgad octgda ocdatg ocdagt ocdtag ocdtga ocdgat ocdgta ocgatd ocgadt ocgtad ocgtda ocgdat ocgdta oactdg oactgd oacdtg oacdgt oacgtd oacgdt oatcdg oatcgd oatdcg oatdgc oatgcd oatgdc oadctg oadcgt oadtcg oadtgc oadgct oadgtc oagctd oagcdt oagtcd oagtdc oagdct oagdtc otcadg otcagd otcdag otcdga otcgad otcgda otacdg otacgd otadcg otadgc otagcd otagdc otdcag otdcga otdacg otdagc otdgca otdgac otgcad otgcda otgacd otgadc otgdca otgdac odcatg odcagt odctag odctga odcgat odcgta odactg odacgt odatcg odatgc odagct odagtc odtcag odtcga odtacg odtagc odtgca odtgac odgcat odgcta odgact odgatc odgtca odgtac ogcatd ogcadt ogctad ogctda ogcdat ogcdta ogactd ogacdt ogatcd ogatdc ogadct ogadtc ogtcad ogtcda ogtacd ogtadc ogtdca ogtdac ogdcat ogdcta ogdact ogdatc ogdtca ogdtac gcatdo gcatod gcadto gcadot gcaotd gcaodt gctado gctaod gctdao gctdoa gctoad gctoda gcdato gcdaot gcdtao gcdtoa gcdoat gcdota gcoatd gcoadt gcotad gcotda gcodat gcodta gactdo gactod gacdto gacdot gacotd gacodt gatcdo gatcod gatdco gatdoc gatocd gatodc gadcto gadcot gadtco gadtoc gadoct gadotc gaoctd gaocdt gaotcd gaotdc gaodct gaodtc gtcado gtcaod gtcdao gtcdoa gtcoad gtcoda gtacdo gtacod gtadco gtadoc gtaocd gtaodc gtdcao gtdcoa gtdaco gtdaoc gtdoca gtdoac gtocad gtocda gtoacd gtoadc gtodca gtodac gdcato gdcaot gdctao gdctoa gdcoat gdcota gdacto gdacot gdatco gdatoc gdaoct gdaotc gdtcao gdtcoa gdtaco gdtaoc gdtoca gdtoac gdocat gdocta gdoact gdoatc gdotca gdotac gocatd gocadt goctad goctda gocdat gocdta goactd goacdt goatcd goatdc goadct goadtc gotcad gotcda gotacd gotadc gotdca gotdac godcat godcta godact godatc godtca godtac
Add a comment
Know the answer?
Add Answer to:
Write a Python program that outputs all possible strings formed by using the characters c ,...
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 code Write a program that will ask the user to input two strings, assign the...

    Python code Write a program that will ask the user to input two strings, assign the strings to variables m and n If the first or second string is less than 10 characters, the program must output a warning message that the string is too short The program must join the strings m and n with the join function The output must be displayed. Please name the program and provide at least one code comment (10)

  • Write a Python program to convert a pdf file to html page. Write Code in Python...

    Write a Python program to convert a pdf file to html page. Write Code in Python Language Only. Please Send Screenshots also Good Answer is Appreciable...

  • In python language please! -Include your Python codes and outputs (a) Write a python program which...

    In python language please! -Include your Python codes and outputs (a) Write a python program which first gets two integers a and b from the user, and then by using an if-elif-else structure, display either ("b is greater than a"), ("a is greater than b"), or ("b is equal to a") (b) use a while loop to determine and print the squares of all integers from 1 to 10

  • In python please. Write a program that reads whitespace delimited strings (words) and an integer (freq)....

    In python please. Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function wordsOfFreqency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter words to the function...

  • Write a program that reads in a sentence of up to 100 characters and outputs the...

    Write a program that reads in a sentence of up to 100 characters and outputs the sentence with spacing corrected and with letters corrected for capitalization. In other words, in the output sentence, all strings of two or more blanks should be compressed to a single blank. The sentence should start with an uppercase letter but should contain no other uppercase letters. Do not worry about proper names; if their first letters are changed to lowercases, that is acceptable. Treat...

  • PYTHON QUESTION PLEASE!! Write a function named problem3 that accepts two strings as the arguments, returns...

    PYTHON QUESTION PLEASE!! Write a function named problem3 that accepts two strings as the arguments, returns the characters that occur in both strings. Test case: the arguments are “apple@123” and “banana@#345”, your program should return “a@3”. Write a function named problem3 that accepts two strings as the arguments, returns the characters that occur in both strings. (20 pts) Test case: the arguments are "apple@123” and “banana@#345”, your program should return "a@3".

  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • Read given code RaceOrNot3.c and write all possible outputs of the program. Assume there will be...

    Read given code RaceOrNot3.c and write all possible outputs of the program. Assume there will be no thread creation or joining failures or semaphore failures. If you believe there is only one possible output, you just need to write that output. #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <errno.h> sem_t s1; int c=0,x=0; void *UpdateC1(void *arg) {    int i;    for(i=0;i<2000000;i++)   {        sem_wait(&s1);        c++;   x++;        sem_post(&s1);    } } void *UpdateC2(void *arg) {    int i,x=0;    for(i=0;i<2999999;i++)   {        sem_wait(&s1);        c++;   x++;       ...

  • Simple Python Program Working with strings Write a Python program to read in a number of...

    Simple Python Program Working with strings Write a Python program to read in a number of strings from the user. Stop when the user enters “Done”. Then check if each of the strings contains all the letters of the alphabet. Print the results in the form of a dictionary, where they keys are the strings and the values are the Truth Value for the string, which you just calculated. Sample Run: Enter the strings: taco cat The quick brown fox...

  • Write a program in java to read a string object consisting 300 characters or more using...

    Write a program in java to read a string object consisting 300 characters or more using index input Stream reader. The program should perform following operations. The String must have proper words and all kind of characters.(Use String class methods). a, Determine the length of the string count the number of letters in the strings , count the number of numeric object d. Calculate the number of special character e. Compute the ratio of the numeric to the total f....

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