answer.
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]
2 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]2 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
Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combinin
Dmitry_Shevchenko [17]

Answer:

Follows are the code to this question:

#include<iostream>//defining header file

using namespace std;// use package

int main()//main method

{

int red,green,blue,x;//declaring integer variable

cin>> red >>green>>blue;//use input method to input value

if(red<green && red<blue)//defining if block that check red value is greater then green and blue  

{

x = red;//use x variable to store red value

}

else if(green<blue)//defining else if block that check green value greater then blue  

{

x= green; //use x variable to store green value

}

else//defining else block

{

x=blue;//use x variable to store blue value

}

red -= x;//subtract input integer value from x  

green -=x; //subtract input integer value from x

blue -= x;//subtract input integer value from x

cout<<red<<" "<<green<<" "<<blue;//print value

return 0;

}

Output:

130 50 130

80 0 80

Explanation:

In the given code, inside the main method, four integers "red, green, blue, and x" are defined, in which "red, green, and blue" is used for input the value from the user end. In the next step, a conditional statement is used, in the if block, it checks red variable value is greater than then "green and blue" variable. If the condition is true, it will store red variable value in "x", otherwise, it will goto else if block.

  • In this block, it checks the green variable value greater than the blue variable value. if the condition is true it will store the green variable value in x variable.
  • In the next step, else block is defined, that store blue variable value in x variable, at the last step input variable, is used that subtracts the value from x and print its value.      
5 0
2 years ago
3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?
Charra [1.4K]

Answer:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

Explanation:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

7 0
2 years ago
Which of the following statements is true? Using existing exceptions makes the program less robust. Always create your own excep
hjlf

Answer:

The third option is correct.

Explanation:

The following option is true because it's a derived with that Throwable class. More than that exception type, it is also other category called Error originating through that Throwable class. As any other class, the exception class will also include fields as well as functions. So, the following are the reason that describes the following answer is true according to the exception class.

The other options are not appropriate according to the following scenario.

8 0
2 years ago
On the planet Sigma, robots excavate chunks of a very precious cristaline. These chunks can be divided into smaller part only on
Rainbow [258]

Answer:

Start the algorithm and check the weight of the ship. Load the crystalline to the ship. Check to see if the ship weighs ship weight + k pound crystalline, if less, add more crystalline. If excess, remove the excess crystalline, but if the weight meets the condition, then take off with the loaded ship to planet sigma.

Explanation:

The algorithm continuously checks the weight of the ship on loading with the calculated sum of the ship and k pound crystalline weight. The ship is able to load the correct maximum amount of crystalline to the planet sigma.

7 0
2 years ago
3. Personal Trainer is very concerned about the security and protection of the information they collect in the new information s
Sever21 [200]

Answer:

Check the explanation

Explanation:

in order to make sure that the built into the new systems, the below input and output levels of security control have to be considered for personal trainers staff.

There are:

   Network Security

   Application security

   Physical security

   User security

   File security

   Procedural security

These securities levels are consistent and advantage in building the decisions regarding system security.

There are the following policies applied to each control:

Network Security: Network interface and traffic controlling, encryption of data.

Application Security: Verification of data input/output and update of software proceedings.

Physical Security: Security to servers, computers and physical environment.

User Security: Protection passwords and identify management skills.

File Security: Access Permission allocated to users and editing authorizations given to users.

Procedural Security: Certify safety protection to perform decision-making activities and document shredders.

Finally, consider another main point is depends the new system performance are system response time, throughput, bandwidth time and turnaround time.

7 0
2 years ago
Other questions:
  • Software code is tested, debugged, fixed, verified, and then:
    11·1 answer
  • Write the definition of a function printLarger, which has two int parameters and returns nothing. The function prints the larger
    15·1 answer
  • Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the givenprogram:Gus Bob Zoeshort_names
    13·1 answer
  • When TCP/IP translates a network layer address into a data link layer address, it sends a special ____________ to all computers
    15·2 answers
  • Justin signed a rental agreement for his new condo. How long is his lease? a p e x
    15·1 answer
  • The domains of the risk IT framework mutually inform each other, creating flexibility and agility. It is possible to uncover a p
    10·1 answer
  • C++
    8·1 answer
  • Longer speeches should be separated into the paragraphs of:
    9·1 answer
  • What are the primary IP addresses for DNS servers hosted on the x128bit, iskytap and cloudparadox domains
    8·1 answer
  • Draw a flowchart and write the algorithm to find even number between 1 to 50​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!