Hướng dẫn how do you use lowercase and uppercase in python? - làm thế nào để bạn sử dụng chữ thường và 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 cách nào để cho phép cả đầu vào dưới và chữ in trong Python?

Giả sử bạn muốn tất cả các ký tự trong chữ thường, những gì bạn có thể làm chỉ là sử dụng hàm sẵn .Lower () cùng với dòng đầu vào.Nó sẽ chấp nhận đầu vào n bất kỳ trường hợp nào và sau đó sẽ chuyển đổi nó thành chữ thường.Tương tự để chuyển đổi nó thành sử dụng trường hợp trên.use the inbuilt function . lower() along with the input line. It will accept the input n any case and will then convert it into lower case. Similarly to convert it into upper case use .

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

SWAPCASE () Phương pháp này được sử dụng để thay đổi các trường hợp từ trường hợp trên sang chữ thường và ngược lại. This method is used to change cases from upper case to lowercase and vice versa.

Việc sử dụng chữ thường trong Python là gì?

.Hạ () là một phương thức Python tích hợp chủ yếu được sử dụng để xử lý chuỗi.Các .Phương thức thấp hơn () không lấy các đối số và trả về các chuỗi thấp hơn từ chuỗi đã cho bằng cách chuyển đổi từng ký tự chữ hoa sang chữ thường.string handling. The . lower() method takes no arguments and returns the lowercased strings from the given string by converting each uppercase character to lowercase.

Có chữ hoa và chữ thường có quan trọng trong Python không?

Python là một ngôn ngữ lập trình nhạy cảm trường hợp.Biến, chức năng, mô -đun và tên gói được viết bằng chữ thường bằng quy ước. Tên và hằng số lớp được viết bằng chữ hoa.Variable, functions, modules and package names are written in lowercase by convention. Class names and constants are written in uppercase.