Method Name:
upper
Method Signature:
upper()
Return Value:
A string of all uppercase characters.
Method Overview:
- For a given string of characters the method uppercase() returns a string whose characters are all in uppercase.
- A Python string is a sequence of Unicode characters. Hence the uppercase() method can convert any string consiting of lowercase characters from languages like Russian into uppercase as given in the Example 2.
Example 1:
|
# Example Python program that converts strings # Lowercase to uppercase # Titlecase to uppercase # Mixed to uppercase |
Output:
|
Lowercase:warning Uppercase:WARNING Titlecase:New York City Uppercase:NEW YORK CITY Mixed case:Lakes of the world Uppercase:LAKES OF THE WORLD |
Example 2 - Convert a string of Cyrillic uppercase alphabets to lowercase:
|
# Example Python program that converts lowercase # Hello world - Russian # Convert to upper case - Russian print("Hello world in Russian(in lower case):") print("Hello world in Russian(in upper case):") print("Unicode | In decimal | In hexadecimal") print("Unicode | In decimal | In hexadecimal") |
Output:
| Hello world in Russian(in lower case): привет, мир! Hello world in Russian(in upper case): ПРИВЕТ, МИР! Unicode | In decimal | In hexadecimal п-1087-0x43f р-1088-0x440 и-1080-0x438 в-1074-0x432 е-1077-0x435 т-1090-0x442 ,-44-0x2c -32-0x20 м-1084-0x43c и-1080-0x438 р-1088-0x440 !-33-0x21 Unicode | In decimal | In hexadecimal П-1055-0x41f Р-1056-0x420 И-1048-0x418 В-1042-0x412 Е-1045-0x415 Т-1058-0x422 ,-44-0x2c -32-0x20 М-1052-0x41c И-1048-0x418 Р-1056-0x420 !-33-0x21 |