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
ehidna [41]
1 year ago
12

Assume the variable myWord references a string. Write a statement that uses a slicing

Computers and Technology
1 answer:
givi [52]1 year ago
3 0

Answer:

"myWord[-5:]"

Explanation:

So whenever you slice a string, the syntax in python is expressed as:

string[a:b:c]

where a=start index (this is included in the sliced string)

b = end index (this is excluded from the sliced string)

c = increment

If any of these are included, they are set to default values, where a=0, b=len(string), and c=1.

The increment isn't necessary here, and it's just so you know the syntax a bit more

Anyways, I'm assuming when the question asks to display "the last 5 characters in the string" it means in order? e.g "abcdefghijk" -> "ghijk" and not "abcdefghijk" -> "kjihg"

The last piece of information to know is what a negative index represents.

For example if I have the piece of code

"

string = "hello world"

print(string[-1])

"

This will output "d", and the negative 1 represents the last letter. If you did -2, it would output the 2nd to last letter and so on.

So to print the last 5 characters, we simply use the -5 as the starting index.  

"

string = "hello world"

print(string[-5:])

"

This will print "world" or in other words, the last 5 letters. The reason for this is because the -5 in the first spot means the starting index is the 5th to last letter, and when you have the : after the -5, this is the way of telling python you're slicing the string, and not indexing 1 character. You don't need to include another value after that, because it will default to the last index of the string, or more specifically the last index + 1, since the last index is still included.

So the last thing to know, is that if the string isn't greater than 5 characters, it just prints the entire string, and no errors are raised. You can test this out your self as well. So whenever you have a string that's less than 5 characters the entire string is outputted.

You might be interested in
The help desk received a call from a user who cannot get any print jobs to print on the locally shared printer. While questionin
erma4kov [3.2K]

Answer:

a. Power cycle the printer.

Explanation:

Power Cycle: To unplug the printer and restart it, is called power cycling. The peripheral devices often tend to stop working and the cause of this is not always easily figured out. So the first and easiest way that can be done to fix this issue is to run a power cycle. For this, you have to turn off the printer and unplug it. Then wait for a few seconds (at least 30) and plug in the printer again. Turn the printer on. Power cycle helps to resolve many basic issues. It is the easiest step to take before checking the printer cable, reinstalling printer or resetting the print spooler.

4 0
2 years ago
Class 00 rubber gloves are used when working with voltages less than​ _____.
Radda [10]
Answer: 500 volts AC, 750 volts DC
Class 00 rubber gloves are given the color "beige" based on the color code of rubber gloves.
The proof test voltage for this class of rubber gloves is 2500 volts of AC voltage and 10000 volts of DC voltage
4 0
2 years ago
1) differentiate between Tittle and caption
Yakvenalex [24]

Answer:

The difference and the steps to insert media in the project can be defined as follows:

Explanation:

Title:

The title is a document, that defines the object that is legally operated.  

Caption:

The Caption is also known as the title or the heading, which described the words on a screen, that conveys the message, that is being said.

Difference:

  • The titles will be assigned to the starting of the clip,  that selects, and charges will be applied to the project at the end.  
  • The caption may also be applied as a text to a specific clip for the reason.

Step to insert any media in the project:

  • Choose the preferred location to insert your media.  
  • Tap on the top of the insert Tab.      
  • Choose the desired media form.  
  • after selecting your desired media, click on the insert button, at this, the media will be inserted.
3 0
3 years ago
What is the definition of a client computer?
kozerog [31]

<u>Client computer:</u>

A customer is a bit of PC equipment or programming that gets to assistance made accessible by a server. The server is frequently (yet not generally) on another PC framework, wherein case the customer gets to the administration by method for a system.

A gathering of customers is generally called a customer framework. The individuals from a customer framework are normally identified with each other in at least one perspective. The customer is likewise another name for a product program used to associate with a server. 3. A customer can likewise be another term used to depict a client.

5 0
2 years ago
2. What may happen if a large number of computer users are attempting to access a Web site at the same time that you are?
Pachacha [2.7K]
The website may crash if it was not built to sustain a large number of viewers.
6 0
3 years ago
Read 2 more answers
Other questions:
  • a supermarket having a sale on canned foods' the sale includes 12 cans of soup for 10.65 what is the unit price per can of soup
    6·2 answers
  • A __engineer specializes in computer hardware design and integration.
    15·1 answer
  • You accidentally find someone's password and use it to get into a system. this is hacking.
    15·1 answer
  • Which is the biggest known issue specific to satellite Internet connections?
    13·2 answers
  • After reading the article, "The Impact of Technology", answer the following question.
    7·1 answer
  • What would happen if your computer was infected with the virus or if your network went down?
    10·2 answers
  • What is the plan to make optimum usage of available spaces?
    15·1 answer
  • ________ are the symbolic codes used in assembly language?​
    6·1 answer
  • 5. Why do we need programming language?​
    13·2 answers
  • Why aren't my skullcandy bluetooth headphones connecting to my school chromebook if I turned on both the headphones and the blue
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!