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
For off campus work study positions, students should contact the
anygoal [31]

Answer:

The answer is "financial aid office".

Explanation:

The work studies are a good way for people to raise funds in component-time on-campus jobs for payment for tuition. In off-campus study, it uses financial aid office, that provides learners to chance to gain useful job experiences when they study at university.

  • It usually works with you even if you have received an admission invitation.
  • In off-campus study work, it uses the department of Financial Aid, in which it is used to find the financial aid office of your school.
  • It can scan the sorted alphabetically lists below.
7 0
3 years ago
What does a linear bus topology used to connect all network devices?
pentagon [3]
<span>A linear bus topology uses a common background cable to connect all network devices.</span>
5 0
3 years ago
The Quake, One of the first fully 3D games was released in the year? 1986 1996 1995​
kipiarov [429]
It was released in 1996
5 0
3 years ago
How do u set up a Wi-Fi network on Android ​
AlladinOne [14]

Answer:

These are some way I know

5 0
3 years ago
)Which of following can be thrown using the throwstatement?
Amanda [17]

Answer:

All of Given

Explanation:

The throw keywords can be used to throw any Throwable object. The syntax is :

throw <Throwable instance>

Note that Error and Exception are subclasses of Throwable while RuntimeException is a subclass of Exception. So the hierarchy is as follows:

Throwable

-- Error

-- Exception

   -- RuntimeException

And all of these are valid throwable entities. As a result "All of Given" is the most appropriate option for this question.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which term describes the order of arrangement of files and folders on a computer?
    11·1 answer
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • Como hacer una pagina web
    15·1 answer
  • which virtue you need to secure information by limiting computer access to authorized personnel only?
    10·1 answer
  • In this website/app what are the points for?
    7·1 answer
  • High capacity circuits are limited by the least capable network link, which is typically the user connection. As such, it is imp
    11·1 answer
  • QUESTION
    10·1 answer
  • When specifying keywords to conduct an internet search, which of the following parts of speech will be the most useful??
    6·1 answer
  • When working in outline mode, press __________ and click the eye icon to change only one layer back to preview mode.
    10·1 answer
  • Is it true that if the user log out the computer will turn off automatically​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!