Hướng dẫn python if char is uppercase - python nếu char là chữ hoa

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 xem một ký tự có ở chữ hoa ở Python không?

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 xem một ký tự trong chuỗi là chữ hoa?

Để kiểm tra xem một chữ cái trong chuỗi có phải là chữ hoa hoặc chữ thường sử dụng phương thức TOUPPERCase () để chuyển đổi chữ cái thành chữ hoa và so sánh nó với chính nó.Nếu so sánh trả về đúng, thì chữ cái được viết hoa, nếu không thì đó là chữ thường.use the toUpperCase() method to convert the letter to uppercase and compare it to itself. If the comparison returns true , then the letter is uppercase, otherwise it's lowercase.

Sự khác biệt giữa trên () và isupper () trong Python là gì?

Isupper () & isLower () trả về các giá trị boolean trong khi hàm trên () & thấp hơn () trả về các chuỗi trong chữ hoa hoặc chữ thường..

Isupper () làm gì trong Python?

Phương thức isupper () trả về đúng nếu tất cả các ký tự ở trường hợp trên, nếu không thì sai.returns True if all the characters are in upper case, otherwise False.