Search Header Logo

Mastering Python Strings (12A-B IT ESSENTIALS)

Authored by Imhotep Brooks

Computers

12th Grade

Used 12+ times

Mastering Python Strings (12A-B IT ESSENTIALS)
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Python code?

lst = [3, 6, 9, 12]

lst.append(lst[2] * 2)

print(lst)

[3, 6, 9, 12, 12]

[3, 6, 9, 12, 18]

[3, 6, 9, 12, 6]

[3, 6, 9, 12, 24]

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you format a string using f-strings in Python?

Use f'string {variable}' to format a string with variables.

Use 'string {variable}' without f prefix.

Format strings with 'format()' method instead.

Concatenate variables using '+' operator.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Python code?

list1 = [1, 2, 3]

list2 = list1

list2.append(4)

print(list1)

[1, 2, 3]

[1, 2, 3, 4]

TypeError

[4, 1, 2, 3]

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method would you use to convert a string to Uppercase?

.lowercase()

.convertToLower()

.upper()

.toLowerCase()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

x = "7.5"

y = int(float(x))

print(y, type(y))

7.5 <class 'int'>

7 <class 'int'>

7.5 <class 'float'>

TypeError

6.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

How can you slice the string 'Programming' to get 'program'?

print(x[2:7])

print(x[0:7])

print(x[3:8])

print(x[-4:])

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Python code?

x = 10 % 5

y = 10 // 3

z = x + y * 2

print(z)

9

8

6

5

Access all questions and much more by creating a free account

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

Already have an account?