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]
2 years ago
12

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

Computers and Technology
1 answer:
givi [52]2 years 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
Is my document folder located at taskbar​
KiRa [710]
Nope its located at your my computer
8 0
3 years ago
What are the disadvantages of a Cessna 172?
Brut [27]

Answer:

The 172 accounted for 17-percent of the active fleet and flew 16-percent of the hours flown while accounting for six-percent of the fatal accidents.

Explanation:

In a two-year period there was but one fatal 172 accident that was due to a mechanical failure. That was an engine failure related to a valve. There were no fatal accidents related to fuel exhaustion or starvation.

Despite the good record in that area, the 172 is probably involved in just as many forced landings as any like airplane. It just appears more adaptable to impromptu arrivals than some other airplanes. The low landing speed contributes to this. There is no available statistic on this, but I would bet that most 172 forced landings don’t result in what the NTSB classifies as an accident.

I looked at fatal 172 accidents that occurred during two more recent years (2012 and 2013) when virtually all the NTSB reports were final as opposed to preliminary. There were 25 such accidents in the 48 contiguous states. If the methodology I used years ago is applied to that number, the 172 safety record appears to have improved, maybe substantially.

6 0
3 years ago
Context-based signatures match a pattern of activity based on the other activity around it, such as a port scan. true and false
valina [46]

Answer:

The given statement is "True".

Explanation:

  • Context-based signatures become wired networks on either the incoming packet's information. Documentation included within the IP headers has been used to stimulate a certificate or stamp based on the scenario.
  • The whole category of signatures examines congestion and how much it appears to fit through the other pedestrians which mostly surrounds it.

So that the above is the true answer.

7 0
3 years ago
Suggest three ways in which celebrating an occasion influences food choices?
Basile [38]

Celebrating influences food in more than 1 way
6 0
3 years ago
Read 2 more answers
Does anybody have the full answer sheet for Cisco Packet Tracer 11.10.1 (Design and implement a vlsm addressing scheme)? Will gi
nalin [4]

Answer:

Red font color or Gray highlights indicate text that appears ... In this lab, you will design a VLSM addressing scheme given a network ... You have been asked to design, implement, and test addressing ...

Explanation:

7 0
3 years ago
Other questions:
  • Which method of encryption is based on physics principles?
    5·1 answer
  • What is the primary purpose of a business plan? To file for incorporation To help you identify your goals and plan how you will
    6·1 answer
  • Discuss the software development methodology you would use for developing a software product for insurance agents, and state val
    10·1 answer
  • The headings that appear on the Ribbon, such as File, Home, and Insert, are called:
    5·1 answer
  • Question 19 :Rachel, a database administrator, has created a database for her website. It contains pictures of vacations that pe
    13·1 answer
  • What do green squiggly lines under text indicate?
    14·1 answer
  • 1.Two robots start out at 426c cm. apart and drive towards each other. The first robot drives at 5 cm per second and the second
    15·1 answer
  • PLEASE HELP!!!
    7·1 answer
  • A flowchart meeting is a process where members of the team analyze the design piece-by-piece to make sure it meets requirements
    15·1 answer
  • Technology?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!