🌍 All Study Guides📊 Dashboard📰 Blog💡 About
Google Cybersecurity Professional Certificate • STUDY MODE

WORK WITH STRINGS

QUESTION 1 OF 5

Which of the following statements correctly describes strings? Select all that apply.

A
Strings are immutable.Correct Answer
B
Strings must be placed in brackets ([ ]).
C
Strings cannot contain numeric characters.
D
Strings must be placed in quotation marks (" ").Correct Answer
Explanation:

Strings must be placed in quotation marks. Strings are also immutable. This means they cannot be changed after they are created and assigned a value.

QUESTION 2 OF 5

What does the following code return? device_id = "uu0ktt0vwugjyf2" print(device_id[2:5])

A
"u0kt"
B
"0kt"Correct Answer
C
"u0k"
D
"0ktt"
Explanation:

This code returns "0kt". It uses bracket notation to take a slice of the value contained in the device_id variable. Indices start at 0 in Python. It extracts the characters at indices 2, 3, and 4. The character at index 5 is excluded from the slice.

QUESTION 3 OF 5

What does the following code display? device_id = "Tj1C58Dakx" print(device_id.lower())

A
"tj1C58Dakx"
B
"Tj1C58Dakx"
C
"tj1c58dakx"Correct Answer
D
"TJ1C58DAKX"
Explanation:

This code displays "tj1c58dakx". The .lower() method converts all uppercase characters into lowercase characters.

QUESTION 4 OF 5

You want to find the index where the substring "192.168.243.140" starts within the string contained in the variable ip_addresses. Complete the Python code to find and display the starting index. (If you want to undo your changes to the code, you can click the Reset button.) (S1Q4-1) (S1Q4-2) What index does the substring "192.168.243.140" start at?

A
31
B
32Correct Answer
C
34
D
33
Explanation:

The substring "192.168.243.140" starts at index 32. You can determine this using the code ip_addresses.index("192.168.243.140"). Note that Python indices start at 0.

QUESTION 5 OF 5

What does the code print("HELLO"[2:4]) output?

A
"LL"Correct Answer
B
"E"
C
"EL"
D
"LLO"
Explanation:

The code print("HELLO"[2:4]) outputs "LL". The first index in the slice is included in the output, but the second index in the slice is not included. This means the slice starts at the character at index 2 and ends one character before index 4.

Ready to test your recall?

Which of the following statements correctly describes strings? Select all that apply.

💡Select all 2 correct answers before submitting (0 of 2 selected).
A
Strings are immutable.
B
Strings must be placed in brackets ([ ]).
C
Strings cannot contain numeric characters.
D
Strings must be placed in quotation marks (" ").

How confident are you in this answer?