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
Lorico [155]
3 years ago
12

#Write a function called "scramble" that accepts a string #as an argument and returns a new string. The new string #should start

with the last half of the original string #and end with the first half. # #If the length of the string is odd, split the string #at the floor of the length / 2 (in other words, the second #half is the longer half). # #For example: # scramble("abcd") -> "cdab" # screamble("abcde") -> "cdeab" # scramble("railroad")) -> "roadrail" # scramble("fireworks")) -> "worksfire"
Computers and Technology
1 answer:
mojhsa [17]3 years ago
8 0

Answer:

def scramble(s):

   if len(s) % 2 == 1:

       index = int(len(s)//2)

   else:

       index = int(len(s)/2)

   

   return s[index:] + s[:index]

Explanation:

Create a function called scramble that takes one parameter, s

Check the length of the s using len function. If the length is odd, set the index as the floor of the length/2. Otherwise, set the index as length/2. Use index value to slice the s as two halves

Return the second half of the s and the second half of the s using slice notation (s[index:] represents the characters from half of the s to the end, s[:index] represents the characters from begining to the half of the s)

You might be interested in
Having a good credit score is important because:
Lisa [10]
It would be better if we could see the options, fully. But from what I can see, it should be B.
7 0
3 years ago
Vitamins and minerals dissolve easily in water.True or false?
noname [10]
True vitamins and minerals dissolves in water
8 0
2 years ago
show how one version of the technology is an improvement over a previous iteration of that same technology
Romashka-Z-Leto [24]
This question has a ton of answers to it but, here are some basic ideas to help you out
- Cars 1900's vs today
- Computers 1980's vs today
- Guns 1800's vs today
- Televisions 1900's vs today
- Telescopes/Microscopes
7 0
2 years ago
Which organization publishes a handbook that describes various occupations? U.S. Department of Defense U.S. Department of Agricu
prohojiy [21]

Answer:

U.S. Bureau of Labor Statistics.

Explanation:

The Bureau of Labor Statistics is a unit of the United States Department of Labor assigned with the task of fact-finding in the field of labor and statistics for the government. The agency helps measure the labor activity in the market and evaluates all forms of activity regarding labor conditions for the government.

This agency also functions or serves as the principal agency for the United States Federal Statistical System. It not only collects information or data but also helps spread the said information to the government. It also published a biennial handbook describing various occupations.

3 0
2 years ago
The incompatibilities in speed between the various devices and the CPU make I/O synchronization difficult, especially if there a
Iteru [2.4K]

Answer:

In a buffer

Explanation:

We can define a buffer as a temporary holding area for data between the various devices and the CPU make I/O synchronization especially if there are multiple devices attempting to do I/O at the same time.

Items stored at the buffer helps to reduce the The incompatibilities in speed between the various devices and the CPU.

3 0
3 years ago
Other questions:
  • Computers are said to use binary data because all computer data is simply a series of Os and 1s.
    10·1 answer
  • A user reports that she can't access the new server used in the accounting department. you check the problem and find out that h
    9·1 answer
  • The create_python_script function creates a new python script in the current working directory, adds the line of comments to it
    9·1 answer
  • The work principle is not always true<br> T or F
    11·2 answers
  • What type of engineer is needed in the following scenario?
    7·2 answers
  • Anyone wanna play roblox?? My user is Tsvetok_luis
    11·2 answers
  • Some computer engineering students decided to revise the LC-3 for their senior project. In designing the LC-4, they decided to c
    13·1 answer
  • What is a traffic controller?what are its functions?
    13·1 answer
  • Difference between statement x=+5 and x+=5​
    7·1 answer
  • Need help on Assignment 4: Evens and Odds
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!