Python - Slicing Strings - 2

Python - Slicing Strings - 2

Assessment

Flashcard

Other

12th Grade

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

10 questions

Show all answers

1.

FLASHCARD QUESTION

Front

What does slicing a string in Python allow you to do?

Back

Return a range of characters by using the slice syntax.

2.

FLASHCARD QUESTION

Front

What is the correct way to get the characters from position 2 to position 5 in a string named 'b'? Options: b.slice(2,5), b(2:5), b[2,5], b[2:5]

Back

b[2:5]

3.

FLASHCARD QUESTION

Front

How can you get the characters from the start to position 5 in a string?

Back

Leave out the start index in the slice syntax.

4.

FLASHCARD QUESTION

Front

What does using a negative index in string slicing allow you to do?

Back

Start the slice from the end of the string.

5.

FLASHCARD QUESTION

Front

To get the characters from position 2 to the end of the string, you would:

Back

Leave out the end index in the slice syntax.

6.

FLASHCARD QUESTION

Front

What is the result of slicing the string 'Hello, World!' with the slice [-5:-2]?

Back

'orl'

7.

FLASHCARD QUESTION

Front

Which of the following is not a valid string method in Python? format(), slice(), replace(), lower()

Back

slice()

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?