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:
- To give you 100 statements, for a
running 100 times- that loop , You want a random number of 1 to 4 (for the number of syllables). You can import the
randommodule to get the number and you can use therandinkAre there. Let's say you call this numbern_syll. Also, initialize an empty string to keep your word.- However, for the original
loop insideloop, you need to create the actual wordn_syllanotherrun the loop Start forOn each run, select the letter (see) randomly. Combine it with the word string.- When you pop out of the internal loop, you should have a random word Just print it out!
- that loop , You want a random number of 1 to 4 (for the number of syllables). You can import the
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.