×

Python String isupper() method

Python String isupper() method

The String.isupper() method in Python returns a boolean value ‘true’ if all cased characters in the string are uppercase else for any other value is returns false.

Syntax

String.isupper()

Parameter

NA

Return

This method returns a Boolean value true if all the characters in the specified string are uppercased else it returns false.

Example 1

 # Python program explaining
 # the string.isupper() method
 # initializing the string value
 string = 'TUTORIALSANDEXAMPLES'
 print("String 1:",string)
 print("The above string is upper cased:",string.isupper()) 
  #initializing second string value
 string = 'TutorialsAndEXAMPLES'
 print("String 2:",string)
 print("The above string is upper cased:",string.isupper()) 

Output

 String 1: TUTORIALSANDEXAMPLES
 The above string is upper cased: True
 String 2: TutorialsAndEXAMPLES
 The above string is upper cased: False 

Example 2

 # Python program explaining
 # the string.isupper() method
 # initializing the string value
 string = "PYTHON IS AN EASY PROGRAMMING LANGUAGE"
 print("String 1:",string)
 if string.isupper() == True:
   print('The above string does not contain a lowercase letter.\n')
 else:
   print('The above string contains a uppercase letter.\n')
 string = "It IS VERY SIMPLE TO EXCEcute"
 print("String 2:",string)
 if string.isupper() == True:
   print('The above string does not contain a lowercase letter.')
 else:
   print('The above string contains a lowercase letter.') 

Output

 String 1: PYTHON IS AN EASY PROGRAMMING LANGUAGE
 The above string does not contain a lowercase letter.
 String 2: It IS VERY SIMPLE TO EXCEcute
 The above string contains lowercase letter. 

Example 3

 # Python program explaining
 # the string.isupper() method
 # initializing the string value
 string = "PYTHON IS AN EASY PROGRAMMING LANGUAGE"
 print(string.isupper())
 # passing special characters
 string = "!@#HELLOWORLD"
 #return true the letters in the string are in uppercase
 print(string.isupper())
 # passing whitespace
 string = "HELLO WORLD"
 #return true the letters in the string are in uppercase
 print(string.isupper())
 # passing integer values in the string
 string = "HELLO123 WORLD123"
 #return true the letters in the string are in uppercase
 print(string.isupper())
 string = "HellO123 WORLD123"
 #return false the some letters in the string are in lowercase
 print(string.isupper()) 

Output

 True
 True
 True
 True
 False 

Related Topics

Class and Static Methods in Python

The method is an important concept to learn for every programmer or data analyst. We know that in OOP's concept, each object has its attributes and behaviors defined through methods....

3 minutes read.

Python Variable Scope with Local & Non-local Examples

This article will examine Python's global, local and non-local variables and show you how to use them to write code without problems. Let's quickly review what a variable in Python is...

8 minutes read.

Poolmanager in Python

Python: Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

4 minutes read.

Python Simple Interest

Python is an Object-Oriented high-level language. Python has an English-like syntax, which is very easy to read and write codes. Python is an interpreted language which means that it uses...

3 minutes read.

Python Pascal Triangle

Python Pascal Triangle Pascal triangle A pascal triangle is a number pattern of triangular array of the binomial coefficients. For designing a pascal triangle, we write a function in the program which...

5 minutes read.

Cross Validation in Sklearn

Data scientists can benefit from cross-validation in machine learning in two key ways: it can assist in minimising the amount of data needed and ensure the artificial intelligence model is...

14 minutes read.

Python Logistic Regression with Sklearn & Scikit

In this article, we'll walk through a tutorial for utilising the Python Sklearn (formerly known as Scikit Learn) package to implement logistic regression. To assist you in remembering the concept,...

18 minutes read.

Dynamic Typing in Python

Many key factors for developing a great programming language include how it manages its memory space. This memory space largely depends on empty memory boxes called variables that one creates...

3 minutes read.

Python Switch Case

What is a Switch Case Statement? In the programming languages, a switch statement is a logical loop or syntax that tests the variable's value and compares it with multiple cases. Once...

3 minutes read.

BOTTLE Python Web Framework

The Bottle is a lightweight WSGI micro web framework for python. It acts like a thin wrapper around a web server where it is distributed as a single file module...

4 minutes read.

Parameter Passing in Python

In Python, when we characterize capabilities with default values for specific boundaries, it is said to have its contentions set as a possibility for the client. Clients can either pass their...

3 minutes read.

Create a Table Using Tkinter in Python

Tkinter: The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is...

3 minutes read.

Python Dictionary items() method

Python Dictionary items() method The dictionary.items() method in Python returns a view object that displays a list of dictionary's (key, value) tuple pairs. Syntax dictionary.items() Parameter NA Return This method returns a view object, displaying the list...

1 minute read.

N2 in Python

N2 is known as Nearest Neighbor Algorithm, because it contains 2 N's (N-Nearest, N-Neighbor). This is a library in the python build using C++ and Python. Before N2 was made,...

3 minutes read.

List Comprehension in Python3

List A list in python is a complex data type, and a list is a collection of the number of data. The data variable may or may not be of the...

5 minutes read.

What is a Script in Python

Have you ever heard that Python is a scripting language? Or when people address a Python program file as a script? Besides programming, script generally means "a written story for...

3 minutes read.

Python Write Excel File

Python Write Excel File The Python xlwt module is used to write an excel file and perform multiple operations on it. It can be used to write text, numbers, and formulas for multiple...

3 minutes read.

Python String upper() method

Python String upper() method The string.upper() method in Python returns a copy of the string converted to uppercase. Syntax string.upper() Parameter NA Return This method returns a copy of the string converted to uppercase. Example 1 # Python...

1 minute read.

Python lambda() Function

In this tutorial, we will learn about a new concept known as the Lambda function. It is a relatively new concept while learning Python. Python lambda functions are anonymous functions. It...

3 minutes read.

Python System Command

To execute a program in Python, we need to execute some shell commands to run our program on the computer. Python will provide some shell commands in our background to...

3 minutes read.