Вопрос задан 20.06.2023 в 01:36. Предмет Информатика. Спрашивает Aybar Kundiz.

Заглавные буквы На вход программе подается строка состоящая из имени и фамилии человека,

разделенных одним пробелом. Напишите программу, которая проверяет, что имя и фамилия начинаются с заглавной буквы. Формат входных данных На вход программе подается строка. Формат выходных данных Программа должна вывести «YES» если имя и фамилия начинаются с заглавной буквы и «NO» в противном случае. Примечание. Строка содержит только буквы. Питон ​
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Алиева Руслана.

name = input("Введите имя и фамилию: ").split()

if name[0][0].isupper() and name[1][0].isupper():

   print("YES")

else:

   print("NO")


0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Problem Statement

You need to write a program in Python that checks whether both the first name and last name in a given string start with a capital letter. The program should output "YES" if both names start with a capital letter, and "NO" otherwise.

Input Format

The program takes a string as input. The string consists of a first name and a last name separated by a single space. The string contains only letters.

Output Format

The program should output "YES" if both the first name and last name start with a capital letter. If either the first name or last name does not start with a capital letter, the program should output "NO".

Solution

To solve this problem, you can use the `isupper()` method in Python to check if a character is uppercase. You can apply this method to the first character of both the first name and last name in the given string. If both characters are uppercase, the program should output "YES"; otherwise, it should output "NO".

Here is the Python code that implements this solution:

```python name = input() first_name, last_name = name.split()

if first_name[0].isupper() and last_name[0].isupper(): print("YES") else: print("NO") ```

This code first takes the input string and splits it into the first name and last name using the `split()` method. It then checks if the first character of both the first name and last name is uppercase using the `isupper()` method. If both characters are uppercase, it prints "YES"; otherwise, it prints "NO".

Example

Input: ``` John Doe ```

Output: ``` YES ```

Input: ``` jane Smith ```

Output: ``` NO ```

Input: ``` Alice Johnson ```

Output: ``` YES ```

Please let me know if you need any further assistance.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос