random - Adding items in a list randomly 100 times in Python -


All of you have just started learning about programming and this problem needs to be solved by me, but I am not able to get it: Get your computer to produce 100 of its first statements 1, 2 Sample from the list of 3 or 4 random syllables:

["BA", "BI", "BU", "GA", "GI", "GU" "].

You must write a program that prints 100 types of random interpretations of this type You need to select a random length (1, 2,3 or 4 syllables) for each accent, and simultaneously give the selected number of syllables to the sample above. P>

So there is no point in giving you code, or you will not learn anything, but here are some elements:

  1. To give you 100 statements, for a running 100 times
  2. that loop , You want a random number of 1 to 4 (for the number of syllables). You can import the random module to get the number and you can use the randink Are there. Let's say you call this number n_syll . Also, initialize an empty string to keep your word.
  3. However, for the original loop inside loop, you need to create the actual word n_syll another run the loop Start for On each run, select the letter (see) randomly. Combine it with the word string.
  4. When you pop out of the internal loop, you should have a random word Just print it out!

This is not the best way to do this, but this work will be completed.

If any of these steps are too harsh, maybe to get acquainted with the fundamental knowledge of language can be run through the Codecady Python Tutorial.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -