w3resource

Python: Use double quotes to display strings


Double Quotes String Display

Write a Python program that uses double quotes to display strings.

Pictorial Presentation:

Use double quotes to display strings

Sample Solution:

Python Code:

# Import the 'json' module to work with JSON data.
import json
# Create a Python dictionary with key-value pairs.
data = {'Alex': 1, 'Suresh': 2, 'Agnessa': 3}

# Use the 'json.dumps()' function to convert the dictionary to a JSON-formatted string and print it.
json_string = json.dumps(data)
print(json_string)

Sample Output:

{"Agnessa": 3, "Alex": 1, "Suresh": 2}

Flowchart:

Flowchart:Use double quotes to display strings.

Python Code Editor:

 

Previous: Write a Python program to add leading zeroes to a string.
Next: Write a Python program to split a variable length string into variables.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.