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
Y_Kistochka [10]
3 years ago
5

#We've started a recursive function below called #measure_string that should take in one string parameter, #myStr, and returns i

ts length. However, you may not use #Python's built-in len function. # #Finish our code. We are missing the base case and the #recursive call. # #HINT: Often when we have recursion involving strings, we #want to break down the string to be in its simplest form. #Think about how you could splice a string little by little. #Then think about what your base case might be - what is #the most basic, minimal string you can have in python? # #Hint 2: How can you establish the base case has been #reached without the len() function? #You may not use the built-in 'len()' function.

Computers and Technology
1 answer:
Roman55 [17]3 years ago
6 0

Answer:

Here is the Python program:  

def measure_string(myStr): #function that takes a string as parameter  

 if myStr == '': #if the string is empty (base case)  

      return 0  #return 0  

  else: #if string is not empty  

      return 1 + measure_string(myStr[0:-1]) #calls function recursively to find the length of the string (recursive case)  

#in order to check the working of the above function the following statement is used    

print(measure_string("13 characters")) #calls function and passes the string to it and print the output on the screen      

Explanation:

The function works as following:  

Suppose the string is 13 characters  

myStr = "13 characters"  

if myStr == '': this is the base case and this does not evaluate to true because myStr is not empty. This is basically the alternate of  

if len(myStr) == 0: but we are not supposed to use len function here so we use if myStr == '' instead.  

So the program control moves to the else part  

return 1 + measure_string(myStr[0:-1])  this statement is a recursive call to the function measure_string.  

myStr[0:-1] in the statement is a slice list that starts from the first character of the myStr string (at 0 index) to the last character of the string (-1 index)  

This statement can also be written as:  

return 1 + measure_string(myStr[1:])

or  

return 1 + measure_string(myStr[:-1])  This statement start from 1st character and ends at last character  

This statement keeps calling measure_string until the myStr is empty. The method gets each character using a slice and maintains a count by adding 1 each time this statement is returned.The function breaks string into its first character [0:] and all the rest characters [:-1]. and recursively counts the number of character occurrences and add 1. So there are 13 characters in the example string. So the output is:  

13

You might be interested in
Kerning is the adjustment of space between ___ characters.
IrinaK [193]
Answer: printed

Explanation: The definition of kerning is; the spacing between letters or characters in a piece of text to be printed.

4 0
4 years ago
In excel, a number can contain the characters__
KATRIN_1 [288]
Comma and period? You can have numbers like 123,456.78
7 0
3 years ago
Quinn recently launched a Display campaign for his women's clothing store. Since the launch, his website traffic has increased,
photoshop1234 [79]

<u>Full question:</u>

Quinn recently launched a Display campaign for his women’s clothing store. Since the launch, his website traffic has increased, but sales have remained flat. Which story shows Quinn using remarketing to drive action?

A. Quinn remarkets using his original business objectives and campaigns, with new users from an uploaded compatible list. By leveraging existing materials, he aims to extend his reach while saving cost.

B. Quinn creates a list of cart abandoners that identifies users who visited his website, considered buying his clothing, but didn’t purchase. He shows them an ad with a promotional discount code.

C. Quinn uses the In-Market audience segment for baking supplies with the intent of reaching potential customers while they’re actively browsing for women’s apparel and are close to a conversion.

D. Quinn creates a custom audience segment using keywords and URLs as inputs. He hopes to extend his audience to customers interested in women’s accessories.

Option B

Quinn creates a list of cart abandoners that identifies users who visited his website, considered buying his clothing, but didn’t purchase. He shows them an ad with a promotional discount code shows Quinn using remarketing to drive action

<h3><u>Explanation:</u></h3>

Remarketing is a manner of online advertising that allows sites to exhibit targeted ads to users who have previously hit their site. Remarketing consists of practicing special tracking code to order cookies on the browsers of somebody hitting your website and then assisting ads to those with that cookie.

Because Quinn is dispensing promotional discount code ads to the personality who hit his website, consider purchasing his clothing, but didn’t acquire. Remarketing lets you target those people who have toured your website or entered your app.

4 0
4 years ago
You work in an office that uses Linux and Windows servers. The network uses the IP protocol. You are sitting at a Windows workst
Westkost [7]

Answer:

The ping command.

Explanation:

In a network, workstations known as clients, users or nodes are the devices where data is needed or sents from. A server on the other hand, is a device in the network, configured to render a particular service like database, domain name service, web service etc.

When a link from a workstation to a server is down, the workstation looses connection the server. To confirm the connectivity of the link, "ping" the server ip address from the workstation using the command "ping 'server ip address'". This sends echo packets to the server, which is echoed back if there is connectivity.

6 0
4 years ago
Which programming language's program structure is similar to its syntax?
sashaice [31]

Answer:

I believe it is java.

Explanation:

8 0
3 years ago
Other questions:
  • One of the most obvious initial changes in windows vista is the ____ interface
    10·1 answer
  • To quickly jump to the last cell in a worksheet press ____.
    15·1 answer
  • In the early days of photography, cameras were limited to professional photographers because of the knowledge needed to work the
    15·2 answers
  • What are the factors affecting the purchasing decision for dbms software?
    7·2 answers
  • Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo
    5·1 answer
  • Identify which statement explains why a programmer would break a logic problem into steps.
    13·2 answers
  • Which of the following best describes the protocol used on the internet?
    8·1 answer
  • Greg wants to check the amount of requests his website receives. What test can he use?
    6·1 answer
  • Assume you define a vector in the following way:
    5·1 answer
  • What is the best example of how computers have changed the way people communicate?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!