w3resource

Python: Print Emojis using unicode Characters or CLDR (Common Locale Data Repository ) short names


Print Emojis with Unicode

Write a Python program to print Emojis using Unicode characters or CLDR (Common Locale Data Repository) short names.

Note: The Common Locale Data Repository Project, often abbreviated as CLDR, is a project of the Unicode Consortium to provide locale data in XML format for use in computer applications. CLDR contains locale-specific information that an operating system will typically provide to applications.

Using Unicode characters:

Sample Solution-1:

Python Code:

# Printing a smiling face with heart-eyes using Unicode escape sequence.
print("Smiling face with heart-eyes:")
print("\U0001F60D")

# Printing an unamused face using Unicode escape sequence.
print("Unamused face:")
print("\U0001F612")

# Printing a beaming face with smiling eyes using Unicode escape sequence.
print("Beaming face with smiling eyes:")
print("\U0001F601")

# Printing a grinning face with sweat using Unicode escape sequence.
print("Grinning face with sweat:")
print("\U0001F605")

# Printing a face with tears of joy using Unicode escape sequence.
print("Face with tears of joy:")
print("\U0001F602")

# Printing a slightly smiling face using Unicode escape sequence.
print("Slightly smiling face:")
print("\U0001F642")

# Printing a smiling face with halo using Unicode escape sequence.
print("Smiling face with halo:")
print("\U0001F607")

# Printing a zipper-mouth face using Unicode escape sequence.
print("Zipper-mouth face:")
print("\U0001F910")

# Printing a grinning face using Unicode escape sequence.
print("Grinning face:")
print("\U0001F600")

# Printing a rolling on the floor laughing face using Unicode escape sequence.
print("Rolling on the floor laughing:")
print("\U0001F923")

Sample Output:


Using CLDR Short Names:

Sample Solution-2:

Python Code:

# Printing a rolling on the floor laughing face using Unicode character name.
print("Rolling on the floor laughing:")
print("\N{rolling on the floor laughing}")

# Printing a smiling face with halo using Unicode character name.
print("Smiling face with halo:")
print("\N{smiling face with halo}")

# Printing an unamused face using Unicode character name.
print("Unamused face:")
print("\N{unamused face}")

# Printing a grinning face using Unicode character name.
print("Grinning face:")
print("\N{grinning face}")

# Printing a loudly crying face using Unicode character name.
print("Loudly crying face:")
print("\N{loudly crying face}")

# Printing a face with tears of joy using Unicode character name.
print("Face with tears of joy:")
print("\N{face with tears of joy}")

# Printing a slightly smiling face using Unicode character name.
print("Slightly smiling face:")
print("\N{slightly smiling face}")

# Printing an angry face using Unicode character name.
print("Angry face:")
print("\N{angry face}")

# Printing a zipper-mouth face using Unicode character name.
print("Zipper-mouth face:")
print("\N{zipper-mouth face}")

# Printing a smiling face with sunglasses using Unicode character name.
print("Smiling face with sunglasses:")
print("\N{smiling face with sunglasses}")

Sample Output:


Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to check if every consecutive sequence of zeroes is followed by a consecutive sequence of ones of same length in a given string. Return True/False.
Next: Write a Python program to convert integer to string.

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.