Methods and Functions

Python String isupper()

Python language is having a very rich collection of string built-in functions. These functions are very useful for doing string manipulation. One such function is isupper(). This isupper python function is developed to handle any given string based on the need of case sensitive nature of the string.

The string function in Python isupper() is used to find out whether all of the string’s case-based characters or letters are in uppercase or not. Therefore isupper python function is used to determine whether the given string contains uppercase letters. This article will give a deep and conceptual understanding of isupper python function along with examples.

isupper python

isupper python

Definition:

  • The Python isupper() function will return a True or False value. If all of the alphabets in the given input string are in uppercase then it returns True. On the other hand, if the input string contains at least one alphabet in lowercase then, it returns False.
  • If all the alphabets in a string are uppercase, then the Python isupper()string function returns True; otherwise, it returns False.

isupper() Syntax:

The islupper() function is a built-in string manipulating function in Python. Its syntax is given as:

String.isupper()

isupper() Parameters:

The isupper() function is used for some string values. But, it does not accept any parameters. Therefore isupper python function will return an Error message if any parameters are passed.

Return value of isupper():

Python’s string isupper() function is used to determine the presence of all uppercase alphabets in a string. Thus, it returns a Boolean value as a result. Therefore its return output will be either True or False. True – for all the alphabets in the string only in uppercase. False – if the string contains any one or more alphabet in the string as in lowercase.

It must be noted that isupper() function always returns the “False” value as output if the given string contains only symbols or numerical values. Also, for a string with the combination of one or more alphabets along with symbols and numbers, this function checks the condition and returns True or False accordingly.

Example 1: Return value from isupper() function.

Example

                    
# Python program to illustrate isupper() function.

# All numbers

txt1 = "123486491212321"

print(txt1.isupper())

# All lowercase characters

txt2 = "rraabbcrraabbd"

print(txt2.isupper())

# All uppercase characters

txt3 = "I LOVE INDIA"

print(txt3.isupper())

# Combination of uppercase and lowercase characters with numbers.

txt4= "My vehicle number is 23456"

print(txt4.isupper())

Output:

False

False

True

False

Example 2: Program to illustrate the use of isupper() function.

                    
# Python program to illustrate isupper function

mystring1 = "Python is next generation language"

if mystring1.isupper() == True:

print(" String1 is not containing any lowercase alphabets.")

else:

print("String1 is containing at least one lowercase alphabet.")

mystring2 = "you are a good programmer"

if mystring2.isupper() == False:

print(" String2 is not containing any uppercase alphabets.")

else:

print("String2 is containing all uppercase alphabets.")

Output:

String1 is containing at least one lowercase alphabet.

String2 is not containing any uppercase alphabets.

Errors and Exceptions while using isupper() Python function:

  1. Python isupper() function returns “True” value for whitespaces, but returns “False” if the string contains only whitespace.
  2. Since isupper() function is not accepting any parameter. Therefore it returns an error message due to parameter passing.

Frequently Asked Questions

Q.1: What does islower() mean in Python?

Answer: The python isupper() function is a built-in function to handle specific string operations. It will determine if all of the string’s case-based characters are uppercase. Also, it returns a “True” result, if all the characters in a string are uppercase, otherwise, it returns “False”.

Q.2: How do you capitalize all letters in Python?

Answer: To capitalize all letters in a string in Python there is an in-built function. This is  Python upper() function. We can change all the lowercase characters in any string to uppercase. Thus, it will return a new string having all Capital alphabets. Its syntax is:

string.upper()

Example:

                    
# Python program to illustrate upper() function

mystring = "Python is a new generation language"

newstring=mystring.upper()

print(newstring)

Output:

PYTHON IS A NEW GENERATION LANGUAGE

Q.3: What is the use of islower () and isupper () method in python?

Answer: In Python islower() and isupper() are the built-in functions. These are used to convert lowercase letters into uppercase letters or vice versa. Both are returning Boolean results based on the string given.

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

avatar
  Subscribe  
Notify of

Customize your course in 30 seconds

Which class are you in?
No thanks.