w3resource

Python: Use double quotes to display strings

Python Basic: Exercise-130 with Solution

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/python-basic-exercise-130.php