Search Header Logo

Alsager - CT Block 4

Authored by Richard Steed

Computers

4th Grade

Used 2+ times

Alsager - CT Block 4
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

34 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of placeholders in the string.format() method in Python?

To repeat a string multiple times

To insert variables into a string

To change the font of the string

To calculate mathematical expressions within a string

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct way to use the string.format() method to include the number of cupcakes Alice has in the output?

print("Alice has {} cupcakes.".format("five"))

print("Alice has {5} cupcakes.")

print("Alice has {} cupcakes.".format(5))

print("Alice has {number} cupcakes.".format(5))

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many placeholders are used in the example: print("Bob has {} {}.".format(2, "kittens."))?

1

2

3

4

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output: print("Carl the {1} has a pet {0}!".format("llama", "python"))

Carl the llama has a pet python!

Carl the python has a pet llama!

Carl the {1} has a pet {0}!

Carl the 0 has a pet 1!

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output: print("Elaine submitted {0} {a}".format(10, a = "assignments"))

Elaine submitted {0} {a}

Elaine submitted 10 {a}

Elaine submitted assignments 10

Elaine submitted 10 assignments

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the "{0:.2f}" format specifier in the string.format() method do?

It selects the second item in the format list and formats it as a float with two decimal places.

It selects the first item in the format list and formats it as a float with two decimal places.

It converts the string into a float with two decimal places without selecting any items.

It selects the first item in the format list and formats it as an integer with two decimal places.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet: print("Danny ate £{0:.2f} worth of chocolate!".format(15))?

Danny ate £15 worth of chocolate!

Danny ate £15.00 worth of chocolate!

Danny ate £0.15 worth of chocolate!

Danny ate £1500 worth of chocolate!

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?