Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc method converts all lowercase characters in a string into uppercase characters and returns it
Bàn luận
string.upper[]
Phương thức trên [] chuyển đổi tất cả các ký tự chữ thường trong một chuỗi thành ký tự chữ hoa và trả về nó
Cú pháp:
Thông số :
returns a uppercased string of the given string
Phương pháp upper[]
không có bất kỳ tham số nào. String with only alphabetic characters
Trả lại:
returns a uppercased string of the given string3
returns a uppercased string of the given string4
returns a uppercased string of the given string5
returns a uppercased string of the given string6
returns a uppercased string of the given string3
returns a uppercased string of the given string8
returns a uppercased string of the given string3
returns a uppercased string of the given string4
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS1
returns a uppercased string of the given string6
returns a uppercased string of the given string3
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS4
Mã 1: Chuỗi chỉ có ký tự chữ cái
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS
returns a uppercased string of the given string
0____11 returns a uppercased string of the given string
2 String with alphanumeric characters
Đầu ra:
returns a uppercased string of the given string3
returns a uppercased string of the given string4
returns a uppercased string of the given string5
returns a uppercased string of the given string6
returns a uppercased string of the given string3
returns a uppercased string of the given string8
returns a uppercased string of the given string3
returns a uppercased string of the given string4
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS1
returns a uppercased string of the given string6
returns a uppercased string of the given string3
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS4
Mã 1: Chuỗi chỉ có ký tự chữ cái
Original String: g3Ek5 f0r gE3K5 Converted String: G3EK5 F0R GE3K5
returns a uppercased string of the given string
0____11 returns a uppercased string of the given string
2 One of the common application of upper[] method is to check if the two strings are same or not
Đầu ra:
Mã 2: Chuỗi có ký tự chữ và số
returns a uppercased string of the given string0____11
Original String: geeKs For geEkS Converted String: GEEKS FOR GEEKS7
True1
returns a uppercased string of the given string3
returns a uppercased string of the given string4
True4
returns a uppercased string of the given string6
True6
True7
True1
returns a uppercased string of the given string3
returns a uppercased string of the given string4
True False False1
returns a uppercased string of the given string6
Output:
Strings are same
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc isalpha[] method is used to check whether all characters in the String is an alphabet.
Bàn luận
Phương thức Python StringAsalpha [] được sử dụng để kiểm tra xem tất cả các ký tự trong chuỗi là bảng chữ cái. string.isalpha[]
Chuỗi python isalpha [] Phương thức cú pháp:isalpha[] does not take any parameters
Returns:
- Cú pháp: & nbsp; String.isalpha []: If all characters in the string are alphabet.
- Tham số: isalpha [] không lấy bất kỳ tham số nào: If the string contains 1 or more non-alphabets.
Đúng: nếu tất cả các ký tự trong chuỗi là bảng chữ cái.
- Sai: Nếu chuỗi chứa 1 hoặc nhiều không phải alphabet.
- Lỗi và ngoại lệ:
- Nó không chứa đối số, do đó xảy ra lỗi nếu tham số được truyền
Cả bảng chữ cái viết hoa và chữ thường trở lại
Python3
Không gian không được coi là bảng chữ cái, do đó nó trả về “sai”
returns a uppercased string of the given string3
True False False7
Output:
True
Chuỗi python isalpha [] Phương thức Ví dụ:
Python3
True False False3
returns a uppercased string of the given string1
True False False5
Ví dụ 1: Làm việc của Isalpha []
True False False3
returns a uppercased string of the given string1
Input : string = 'Ayush Saxena' Output : 11 AyushSaxena Input : string = 'Ayush0212' Output : 5 Ayush0
returns a uppercased string of the given string3
True False False7
returns a uppercased string of the given string3
True False False7
returns a uppercased string of the given string3
11 AyushSaxena 5 Ayush2
Output:
True False False
True
False
False
3returns a uppercased string of the given string
1 Input : string = 'Ayush Saxena'
Output : 11
AyushSaxena
Input : string = 'Ayush0212'
Output : 5
Ayush
5
True False False3
returns a uppercased string of the given string1
11 AyushSaxena 5 Ayush0
Input : string = 'Ayush Saxena' Output : 11 AyushSaxena Input : string = 'Ayush0212' Output : 5 Ayush
Algorithm:
- Ví dụ 2: Ứng dụng thực tế
- Đưa ra một chuỗi trong Python, hãy đếm số lượng bảng chữ cái trong chuỗi và in bảng chữ cái.
- Khởi tạo một chuỗi mới và bộ đếm biến thành 0. & nbsp;
- Đi qua ký tự chuỗi đã cho bằng ký tự lên đến chiều dài của nó, kiểm tra xem ký tự là bảng chữ cái. & NBSP;
Python3
11 AyushSaxena 5 Ayush3
returns a uppercased string of the given string1
11 AyushSaxena 5 Ayush0
11 AyushSaxena 5 Ayush6
returns a uppercased string of the given string1
11 AyushSaxena 5 Ayush8
Nếu đó là bảng chữ cái, hãy tăng bộ đếm 1 và thêm nó vào một chuỗi mới, khác đi qua ký tự tiếp theo. & NBSP;
upper[]
2
returns a uppercased string of the given string1
upper[]
1In giá trị của bộ đếm và chuỗi mới.
11 AyushSaxena 5 Ayush9
returns a uppercased string of the given string1
upper[]
1returns a uppercased string of the given string06
11 AyushSaxena 5 Ayush6
returns a uppercased string of the given string08
returns a uppercased string of the given string1
returns a uppercased string of the given string10
returns a uppercased string of the given string06
returns a uppercased string of the given string12
returns a uppercased string of the given string08
returns a uppercased string of the given string1
returns a uppercased string of the given string15
returns a uppercased string of the given string3
returns a uppercased string of the given string17
returns a uppercased string of the given string3
returns a uppercased string of the given string19
11 AyushSaxena 5 Ayush3
returns a uppercased string of the given string1
Input : string = 'Ayush Saxena' Output : 11 AyushSaxena Input : string = 'Ayush0212' Output : 5 Ayush5
11 AyushSaxena 5 Ayush6
returns a uppercased string of the given string1
11 AyushSaxena 5 Ayush8
In giá trị của bộ đếm và chuỗi mới.
11 AyushSaxena 5 Ayush9
returns a uppercased string of the given string1
upper[]
1returns a uppercased string of the given string06
11 AyushSaxena 5 Ayush6
returns a uppercased string of the given string08
returns a uppercased string of the given string1
returns a uppercased string of the given string10
upper[]
5 upper[]
6upper[]
7 upper[]
8
returns a uppercased string of the given string3
returns a uppercased string of the given string17
returns a uppercased string of the given string3
returns a uppercased string of the given string50
Output:
11 AyushSaxena 5 Ayush
Độ phức tạp về thời gian: O [n] O[n]
Không gian phụ trợ: O [n]O[n]