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]
4 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]4 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
What are examples of data duplication in flat files? Check all that apply.
photoshop1234 [79]

Answer:

Flat file databases are databases that are contained in one single table, or in the form ... -Data Redundancy, By having a relational database it ensures that no attributes ... There are only three different 'degrees' of relationship between two entities. ... Consider, for example, the link between customers, orders and products.).

Explanation:

7 0
3 years ago
Read 2 more answers
With a DUI charge on a driver’s record ______________.
Sindrei [870]
When you are charged with DUI or Driving under influence, there are many possible consequences for such crime.

One, your insurance company might require you to increase the price or upgrade your subscription to premium. Or, worst case is they will terminate your subscription immediately upon knowing.

4 0
3 years ago
Can someone please answer this for me I will answer one of yours.
julsineya [31]
4 is preview i think.
4 0
4 years ago
For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a comma (no sp
givi [52]

Answer:

u look se33y yessir

Explanation:

......................................

7 0
3 years ago
During the system investigation stage, __________ studies are done to determine if the hardware, software, and communications co
oksano4ka [1.4K]

Answer:

The correct answer is "Technical Feasibility".

Explanation:

System investigation is used to Review that whether the system is feasible or not for the proposal that they will design or creating.in the system investigation stage, we do the technical feasibility. The technical feasibility is used to check technical resources like hardware, software, etc in the organization.

The  Technical Feasibility in the System investigation  is used to solve the problem of business

6 0
4 years ago
Other questions:
  • There are three required elements needed to connect to the internet: internet service provider, hardware, and __________.
    13·1 answer
  • What version of android did nexus one run?
    14·1 answer
  • Write the equivalent c++ expression for the following algebraic expressions
    11·1 answer
  • I play Among us :) hbu
    7·2 answers
  • Write a Java program to accept an item's name and price from the user and output them to the console
    5·1 answer
  • if an open cut or wound is exposed to contamination washing it in hot water and hand soap is not sufficient to keep safe
    14·2 answers
  • Which flowchart symbol indicates the start or the end of a process?
    8·1 answer
  • Anyone know how to fix black screen of death on computer​
    6·1 answer
  • 4. When working at the CLI in Linux, you specify the exact location of a file, which is the ____________________ to it, by begin
    13·1 answer
  • Answer pls pls pls pls ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!