How To Convert Lowercase To Uppercase In Python
Last Updated : Jul 1, 2023
In this article we will show you the solution of how to convert lowercase to uppercase in python, an uppercase to lowercase conversion Python application.
There are two parallel sets of characters in writing systems that discriminate between uppercase and lowercase letters, and each letter in one set typically has an identical in the other.
In contrast to their larger, taller counterparts, uppercase letters are the smaller, shorter variants of letters (like w). Now let us discuss the idea of uppercase to lowercase conversion in Python.
Step By Step Guide On How To Convert Lowercase To Uppercase In Python :-
Method - Lowercase to Uppercase String without Function
print("Enter String: ", end="") text = input() for i in range(len(text)): if text[i]>='a' and text[i]<='z': ch = text[i] ch = ord(ch) ch = ch-32 ch = chr(ch) text = text[:i] + ch + text[i+1:] print("\nIts Uppercase:", text)
- Here you can see that we write the python code for converting lowercase to uppercase in python with the help of string without function.
- This program is created to operate with string.
- That is, this program converts lowercase string entered by user to its equivalent uppercase string.
- In the beginning of the code we take some text in input format from the user.
- After that we used for loop for scanning all the characters present in the string.
- Then compared whether the character at current index is a lowercase character or not.
- If the character found as a lowercase character, then that character gets converted into uppercase.
- new string after converting the current index's character to uppercase, gets initialized as new value of text.
- We also use len, here len is the length of string.
- While slicing the string using indexing, that is [:], the index number before colon is included, whereas the index number after colon is excluded.
- And in the last we use the print function for printing the string taken from user in uppercase letters.
Method - Using ASCII values, convert lowercase to uppercase characters.
print("Enter the Character: ") ch = input() chup = ord(ch) chup = chup-32 chup = chr(chup) print("\nIts Uppercase is: ", chup)
- Here you can see that we write the python code for converting lowercase to uppercase in python.
- This program uses ASCII value of character to convert the character in uppercase.
- We take user input in string format at the beginning of the function.
- Then ord() method is then used to determine the Unicode value of such a character that is supplied as an argument.
- Next, we utilise the chr() method to locate the character that corresponds to the Unicode value that was supplied as its argument.
- It states that the value of chup gets subtracted with 32. This statement is used to initialize the ASCII value of corresponding uppercase character.
- Then the character corresponding to the ASCII value of 67, that is C gets initialized to chup. The character is changed to uppercase in this manner.
- In the last we use print function in python for printing the conversion of string from lowercase to uppercase.
Hence we have successfully learned the concept of how to convert lowercase to uppercase in python.
We also learned that the conversion of string with ASCII value and string without function.
As well as we learned that Uppercase letters are also known as capital letters.
Uppercase letters signal to the reader that something is important or significant. In writing, most letters are lowercase.
Lowercase letters are all letters that do not begin a sentence or refer to a proper noun.
I hope this article on how to convert lowercase to uppercase in python helps you and the steps and method mentioned above are easy to follow and implement.