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
Your friend decides to create a spreadsheet containing vocabulary terms and their definitions to help prepare for the unit test
Nataly_w [17]

Answer:

The answer is SORT

Explanation:

Just did the test :)

6 0
2 years ago
Which key removes all data from an active cell with one click
Aleks [24]
Hello,

Here is your answer:

The proper answer tot his question will be the "delete key"! This key allows you to delete all the data in a certain cell!

Your answer is delete!

If you need anymore help feel free to a ask me!

Hole this helps!

4 0
3 years ago
Read 2 more answers
3. When code tracing, why is it important to iteratively test parts of the program?
GenaCL600 [577]

Answer:

A. To isolate errors in the outcomes of code.

<em>Hope this helps! ^-^</em>

<em>-Isa</em>

7 0
3 years ago
Which option identifies what the computer will yield in the following scenario?
dolphi86 [110]
I think it would be the computer program will create a design with the exact dimensions
6 0
2 years ago
If I had to choose the class I prefer it would be a
dmitriy555 [2]
How about you prefer no class
4 0
3 years ago
Other questions:
  • What is the name of the process of heat transfer in which heat is transmitted through light waves?
    7·2 answers
  • I plugged my phone up into a charger, the charger sparked and i unplugged my phone and now it wont charge at all, does anyone kn
    13·1 answer
  • If you work up to your potential but fall short of your goals, you
    15·2 answers
  • Special programs that facilitate communication between a device and the os are called
    12·1 answer
  • Complete the paragraph describing characteristics of an audio mixer
    8·2 answers
  • python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T
    12·1 answer
  • How does it transform your ways of socializing
    11·1 answer
  • Choose the best type of loop for each situation.
    6·1 answer
  • The transmission control protocol (TCP) layer helps computers to communicate in which of the following ways?
    10·1 answer
  • Expectation on Information Technology Fundamental​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!