Hướng dẫn how do you check if something is uppercase in python? - làm thế nào để bạn kiểm tra xem một cái gì đó là chữ hoa trong python?

Trong bài viết này, chúng tôi sẽ thảo luận về các hàm isupper (), isLower (), up () và lower () trong python. Các phương pháp này là các phương pháp tích hợp được sử dụng để xử lý chuỗi. Trước khi nghiên cứu chúng một cách chi tiết, hãy để một ý tưởng cơ bản về chúng.isupper(), islower(), upper(), and lower() functions in Python. These methods are built-in methods used for handling strings. Before studying them in detail let’s get a basic idea about them.

Isupper () trong python là gì

Trong Python, isupper () là một phương pháp tích hợp được sử dụng để xử lý chuỗi. Phương thức này trả về true nếu tất cả các ký tự trong chuỗi là chữ hoa, nếu không, trả về false false. & Nbsp;True if all characters in the string are uppercase, otherwise, returns “False”. 

  1. Nó trả về một cách đúng sự thật cho các không gian trắng nhưng nếu chỉ có khoảng trắng trong chuỗi thì hãy trả về Sai Sai.
  2. Do đó, nó không có bất kỳ đối số nào, nó sẽ trả về một lỗi nếu một tham số được truyền.
  3. Các chữ số và ký hiệu trả về trực tiếp, nhưng nếu chuỗi chỉ chứa các chữ số và số thì sau đó trả về “sai”

Hàm này được sử dụng để kiểm tra xem đối số có chứa bất kỳ ký tự chữ hoa nào như:

Input: string = 'GEEKSFORGEEKS'
Output: True

Input: string = 'GeeksforGeeks'
Output: False

Cú pháp của & nbsp; isupper () & nbsp;

Cú pháp: String.isupper () & nbsp; string.isupper() 

Parameters: 

  • isupper () không lấy bất kỳ tham số & nbsp;

Trả về: Đúng- Nếu tất cả các ký tự trong chuỗi là chữ hoa. Sai- Nếu chuỗi chứa 1 hoặc nhiều ký tự không tăng cấp. True- If all characters in the string are uppercase. False- If the string contains 1 or more non-uppercase characters.

Thí dụ:

Python3

True
False
0____11
True
False
2

True
False
3
True
False
4

True
False
0____11
True
False
7

True
False
3
True
False
4

Output:

True
False

Islower () trong python là gì

Trong Python, Islower () là một phương thức tích hợp được sử dụng để xử lý chuỗi. Phương thức isLower () trả về true nếu tất cả các ký tự trong chuỗi là chữ thường, nếu không, trả về FALL FALSE. & NBSP;True if all characters in the string are lowercase, otherwise, returns “False”. 

  1. Nó trả về một cách đúng sự thật cho các không gian trắng nhưng nếu chỉ có khoảng trắng trong chuỗi thì hãy trả về Sai Sai.
  2. Do đó, nó không có bất kỳ đối số nào, nó sẽ trả về một lỗi nếu một tham số được truyền.
  3. Các chữ số và ký hiệu trả về trực tiếp, nhưng nếu chuỗi chỉ chứa các chữ số và số thì sau đó trả về “sai”

Hàm này được sử dụng để kiểm tra xem đối số có chứa bất kỳ ký tự chữ hoa nào như:

Cú pháp của & nbsp; isupper () & nbsp;

Cú pháp: String.isupper () & nbsp;

isupper () không lấy bất kỳ tham số & nbsp;string.islower()

Parameters:

  • Trả về: Đúng- Nếu tất cả các ký tự trong chuỗi là chữ hoa. Sai- Nếu chuỗi chứa 1 hoặc nhiều ký tự không tăng cấp.

Returns:

  • Thí dụ:
  • True
    False
    0____11
    True
    False
    2

True False0____11 True False7

Python3

Islower () trong python là gì

True
False
3
Input: string = 'geeksforgeeks'
Output: True

Input: string = 'GeeksforGeeks'
Output: False
4

True
False
0____11
True
False
7

True
False
3
Input: string = 'geeksforgeeks'
Output: True

Input: string = 'GeeksforGeeks'
Output: False
4

Output:

True
False

Islower () trong python là gì

Trong Python, Islower () là một phương thức tích hợp được sử dụng để xử lý chuỗi. Phương thức isLower () trả về true nếu tất cả các ký tự trong chuỗi là chữ thường, nếu không, trả về FALL FALSE. & NBSP;

  1. Do đó, nó không có bất kỳ đối số nào, nó sẽ trả về một lỗi nếu một tham số được truyền.
  2. Các chữ số và ký hiệu trả về trực tiếp, nhưng nếu chuỗi chỉ chứa các chữ số và số thì sau đó trả về “sai”
Input: string = 'GEEKSFORGEEKS'
Output: geeksforgeeks

Input: string = 'GeeksforGeeks'
Output: geeksforgeeks

Hàm này được sử dụng để kiểm tra xem đối số có chứa bất kỳ ký tự chữ hoa nào như:

Cú pháp của & nbsp; isupper () & nbsp; string.lower()

Parameters:

  • Cú pháp: String.isupper () & nbsp;

isupper () không lấy bất kỳ tham số & nbsp;It converts the given string in into lowercase and returns the string.

Examples:

Python3

True
False
0____11
True
False
2

True
False
3
True
False
4

True
False
0____11
True
False
7

True
False
3
True
False
4

Output:

geeksforgeeks
geeksforgeeks

Islower () trong python là gì

Trong Python, Islower () là một phương thức tích hợp được sử dụng để xử lý chuỗi. Phương thức isLower () trả về true nếu tất cả các ký tự trong chuỗi là chữ thường, nếu không, trả về FALL FALSE. & NBSP;

  1. Do đó, nó không có bất kỳ đối số nào, nó sẽ trả về một lỗi nếu một tham số được truyền.
  2. Các chữ số và ký hiệu trả về trực tiếp, nhưng nếu chuỗi chỉ chứa các chữ số và số thì sau đó trả về “sai”
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH

Hàm này được sử dụng để kiểm tra xem đối số có chứa bất kỳ ký tự chữ hoa nào như:

Cú pháp của & nbsp; isupper () & nbsp;string.upper()

Parameters:

  • Cú pháp: String.isupper () & nbsp;

isupper () không lấy bất kỳ tham số & nbsp;It converts the given string in into uppercase and returns the string.

Example:

Python3

Islower () trong python là gì

True
False
3
Input: string = 'GEEKSFORGEEKS'
Output: geeksforgeeks

Input: string = 'GeeksforGeeks'
Output: geeksforgeeks
4

Trong Python, Islower () là một phương thức tích hợp được sử dụng để xử lý chuỗi. Phương thức isLower () trả về true nếu tất cả các ký tự trong chuỗi là chữ thường, nếu không, trả về FALL FALSE. & NBSP;

True
False
3
Input: string = 'GEEKSFORGEEKS'
Output: geeksforgeeks

Input: string = 'GeeksforGeeks'
Output: geeksforgeeks
4

Output:

GEEKSFORGEEKS
MY NAME IS AYUSH

Các chữ số và ký hiệu trả về trực tiếp, nhưng nếu chuỗi chỉ chứa các chữ số và số thì sau đó trả về Sai False.

Hàm này được sử dụng để kiểm tra xem đối số có chứa bất kỳ ký tự thường nào như:

Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH

Input: string = 'geeksforgeeks'
Output: True

Input: string = 'GeeksforGeeks'
Output: False

  1. Cú pháp của Islower ()
  2. Cú pháp: String.islower ()
  3. isLower () không lấy bất kỳ tham số nào
  4. Đúng- nếu tất cả các ký tự trong chuỗi thấp hơn.

Example:

Python3

True
False
0____11
geeksforgeeks
geeksforgeeks
2

geeksforgeeks
geeksforgeeks
3
True
False
1
geeksforgeeks
geeksforgeeks
5

geeksforgeeks
geeksforgeeks
6
True
False
1
geeksforgeeks
geeksforgeeks
8

geeksforgeeks
geeksforgeeks
9
True
False
1
geeksforgeeks
geeksforgeeks
8

Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
2
True
False
1
geeksforgeeks
geeksforgeeks
8

Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
5
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
6
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
7
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
8

Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
9
GEEKSFORGEEKS
MY NAME IS AYUSH
0
GEEKSFORGEEKS
MY NAME IS AYUSH
1
True
False
1
True
False
1
GEEKSFORGEEKS
MY NAME IS AYUSH
4
GEEKSFORGEEKS
MY NAME IS AYUSH
5

GEEKSFORGEEKS
MY NAME IS AYUSH
6
geeksforgeeks
geeksforgeeks
6
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
0

GEEKSFORGEEKS
MY NAME IS AYUSH
6
geeksforgeeks
geeksforgeeks
3
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
5

Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
9
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
7
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
8
True
False
1
True
False
1
GEEKSFORGEEKS
MY NAME IS AYUSH
4
GEEKSFORGEEKS
MY NAME IS AYUSH
5

GEEKSFORGEEKS
MY NAME IS AYUSH
6
geeksforgeeks
geeksforgeeks
9
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
0

GEEKSFORGEEKS
MY NAME IS AYUSH
6
geeksforgeeks
geeksforgeeks
3
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
True
False
02

Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
9
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
7
True
False
05
True
False
1
True
False
1
GEEKSFORGEEKS
MY NAME IS AYUSH
4
GEEKSFORGEEKS
MY NAME IS AYUSH
5

GEEKSFORGEEKS
MY NAME IS AYUSH
6
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS

Input: string = 'My name is ayush'
Output: MY NAME IS AYUSH
2
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
Input : string = 'GeeksforGeeks is a computer Science portal for Geeks'
Output : Uppercase - 4
         Lowercase - 41
         spaces - 7
         gEEKSFORGEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Input : string = 'My name is Ayush'
Output : Uppercase - 2
         Lowercase - 11
         spaces - 3
         mY NAME IS aYUSH
0

GEEKSFORGEEKS
MY NAME IS AYUSH
6
geeksforgeeks
geeksforgeeks
3
GEEKSFORGEEKS
MY NAME IS AYUSH
8
True
False
1
True
False
19

True
False
3
True
False
21
True
False
22
True
False
23

True
False
3
True
False
21
True
False
26
True
False
27

True
False
3
True
False
21
True
False
30
True
False
31

True
False
3
True
False
21
True
False
34
True
False
35

True
False
3
True
False
21
True
False
38
True
False
23

True
False
3
True
False
41

Output:

In original String : 
Uppercase - 4
Lowercase - 41
Spaces - 7
After changing cases:
gEEKSFORgEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Làm thế nào để bạn kiểm tra chữ hoa trong Python?

Trong Python, isupper () là một phương pháp tích hợp được sử dụng để xử lý chuỗi.Phương thức này trả về true nếu tất cả các ký tự trong chuỗi là chữ hoa, nếu không, sẽ trả về FALS FALSE.isupper() is a built-in method used for string handling. This method returns True if all characters in the string are uppercase, otherwise, returns “False”.

Làm thế nào để bạn kiểm tra chữ thường và chữ hoa trong Python?

Sử dụng islower () và isupper () để kiểm tra xem một chuỗi trên, dưới hoặc trường hợp hỗn hợp.Gọi str.isLower () với str là một chuỗi để xác định xem str là tất cả các chữ thường. to check if a string is upper, lower, or mixed case. Call str. islower() with str as a string to determine if str is all lowercase.

Làm thế nào để bạn kiểm tra xem một chuỗi là chữ hoa?

Đi qua ký tự chuỗi theo ký tự từ đầu đến cuối.Kiểm tra giá trị ASCII của mỗi ký tự cho các điều kiện sau: Nếu giá trị ASCII nằm trong phạm vi [65, 90], thì đó là một chữ cái viết hoa.Nếu giá trị ASCII nằm trong phạm vi [97, 122], thì đó là một chữ cái viết thường.If the ASCII value lies in the range of [65, 90], then it is an uppercase letter. If the ASCII value lies in the range of [97, 122], then it is a lowercase letter.