1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Romashka [77]
3 years ago
7

Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1

2, 1112, 3112, 132112, 1113122112, 311311222112, 13211321322112, ...To get a number in the sequence, enumerate how many there are of each digit (in a row) in the previous number. For example, the first number is "one 2", which gives us the second number "12". That number is "one 1" followed by "one 2", which gives us the third number "1112". That number is "three 1" followed by "one 2", or 3112. Etc.
Computers and Technology
1 answer:
-BARSIC- [3]3 years ago
6 0

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

You might be interested in
In which of the following situations may the taxpayer take an education expense on Schedule C? a. Henry, a self-employed adminis
daser333 [38]

Answer:

Henry, an administrative assistant, is taking an advanced Word computer program class through an adult school program.  

Explanation:

4 0
3 years ago
You can apply several different worksheet themes from which tab?
Nookie1986 [14]

page layout...... im not sure

6 0
3 years ago
Read 2 more answers
Why might an algorithm created to assist in hiring decisions be biased?
nika2105 [10]

Answer:

Previous decisions were flawed

Explanation:

An algorithm depends entirely on the data input into the system in the decision making process.

As such, when there are conclusions in the data set used by the algorithm for decision making which are distorted, such as the association of less individuals that drink and drive in the rich cities than can be found in poorer communities due to the presence of less bars uptown and as such drivers from uptown areas are given preference may include a bias that is due to conclusion on which the previous decisions were made and used in the algorithm which may have been flawed or need more detailed analysis

4 0
3 years ago
On Microsoft teams, how do teachers know that you are on a different page?
emmasim [6.3K]

Answer:

they can view if you left the page on the teacher side of the website

Explanation:

i have made a page just for this

6 0
3 years ago
Read 2 more answers
_____ can be used to convert digitized documents into ASCII (American Standard Code for Information Interchange) text that can b
solniwko [45]

Answer:

Optical Character Recognition

Explanation:

Optical Character Recognition is a method that is used to read character and bar codes. They convert scanned image into digital format. In other words ASCII text can be formed when a digitized document is converted.OCR is a method that convert document into word.

Here are some OCR tools which convert digitized format into machine readable text.

  • Microsoft Document
  • Microsoft One Note

8 0
3 years ago
Other questions:
  • What is an (CR) Optical character recognition?
    13·2 answers
  • A powerpoint ________ is a set of unified design elements.
    5·1 answer
  • As a load is mechanically lifted, the materials ____________________.
    7·1 answer
  • Use NumPy to recreate your answer to Question 1b. The input parameters will both be python lists, so you will need to convert th
    8·1 answer
  • What are some ways tables can be inserted into a document? Check all that apply.
    5·2 answers
  • Benjamin recently issued new mobile phones to the marketing team at his company. Each phone can transmit encrypted information f
    8·1 answer
  • Quinton is having trouble learning Spanish because he keeps reverting back to the grammatical structures of his native English l
    6·1 answer
  • Which of the following is NOT a valid name for a function?
    5·1 answer
  • How many sets of number do both Hex and RGB values have?
    10·1 answer
  • The most widely used computer device​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!