Search Header Logo

String Formatting in Python

Authored by Teetreeo Pittman

Other

12th Grade

Used 6+ times

String Formatting in Python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the result of the following code? name = 'John' age = 25 message = 'My name is ' + name + ' and I am ' + str(age) + ' years old.' print(message)

My name is John and I am 25 years.

My name is John and I am 25 years old!

My name is John and I am 25 years old.

My name is John and I am 25.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is string formatting with placeholders in Python?

A technique to convert strings into integers using placeholders and the % operator.

A method to concatenate strings in Python.

A way to remove values from a string using placeholders and the % operator.

A way to insert values into a string using placeholders and the % operator.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the + operator in Python?

The purpose of the + operator in Python is to perform addition or string concatenation.

The purpose of the + operator in Python is to perform subtraction.

The purpose of the + operator in Python is to perform multiplication.

The purpose of the + operator in Python is to perform division.

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the * operator in Python?

The * operator in Python is used for addition of two numbers.

The * operator in Python is used for division of two numbers.

The * operator in Python is used for multiplication of two numbers or for repeating a string a certain number of times.

The * operator in Python is used for subtraction of two numbers.

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the str() function in Python?

To convert any data type to a string data type

To create a new string variable

To convert a string to another data type

To delete a string variable

6.

FILL IN THE BLANK QUESTION

2 mins • 1 pt

Complete the following code to make the string all lowercase:

message = "My buddy Brandon is a GREAT basketball player for his age!"

print(message._____())

7.

MULTIPLE CHOICE QUESTION

1 min • 5 pts

Which answer completes the following code to capitalize the first letter of the first word?

bugsb = What's your favorite cartoon?

print(bugsb.______())

Swapcase

Upper

Capitalize

Isupper

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?