Hello введенное имя введенная фамилия you just delved into python

What’s Your Name? Python

Consider a lowercase English alphabetic letter character denoted by c. A shift operation on some c turns it into the next letter in the alphabet. For example, and ,shift(a) = b , shift(e) = f, shift(z) = a . Given a zero-indexed string, s, of n lowercase letters, perform q queries on s where each query takes one of the following two forms: 1 i j t: All letters in the inclusive range from i t

Counting On a Tree

Taylor loves trees, and this new challenge has him stumped! Consider a tree, t, consisting of n nodes. Each node is numbered from 1 to n, and each node i has an integer, ci, attached to it. A query on tree t takes the form w x y z. To process a query, you must print the count of ordered pairs of integers ( i , j ) such that the following four conditions are all satisfied: the path from n

Polynomial Division

Consider a sequence, c0, c1, . . . , cn-1 , and a polynomial of degree 1 defined as Q(x ) = a * x + b. You must perform q queries on the sequence, where each query is one of the following two types: 1 i x: Replace ci with x. 2 l r: Consider the polynomial and determine whether is divisible by over the field , where . In other words, check if there exists a polynomial with integer coefficie

Costly Intervals

Given an array, your goal is to find, for each element, the largest subarray containing it whose cost is at least k. Specifically, let A = [A1, A2, . . . , An ] be an array of length n, and let be the subarray from index l to index r. Also, Let MAX( l, r ) be the largest number in Al. . . r. Let MIN( l, r ) be the smallest number in Al . . .r . Let OR( l , r ) be the bitwise OR of the

The Strange Function

One of the most important skills a programmer needs to learn early on is the ability to pose a problem in an abstract way. This skill is important not just for researchers but also in applied fields like software engineering and web development. You are able to solve most of a problem, except for one last subproblem, which you have posed in an abstract way as follows: Given an array consisting

Self-Driving Bus

Treeland is a country with n cities and n — 1 roads. There is exactly one path between any two cities. The ruler of Treeland wants to implement a self-driving bus system and asks tree-loving Alex to plan the bus routes. Alex decides that each route must contain a subset of connected cities; a subset of cities is connected if the following two conditions are true: There is a path between ever

Читайте также:  What is radio button in html

Источник

Решение модуля 6.2 «Поколение Python»

Все решения и ответы на модуль (урок) 6.2 из программы «Поколение Python: курс для начинающих».

Целью этого занятия будет научиться работать со строками и производить операции с ними.

Что покажет приведенный ниже фрагмент кода?

mystr = ‘да’
mystr = mystr + ‘нет’
mystr = mystr + ‘да’
print(mystr)

Ответ: данетда

Что покажет приведенный ниже фрагмент кода?

str1 = ‘1’
str2 = str1 + ‘2’ + str1
str3 = str2 + ‘3’ + str2
str4 = str3 + ‘4’ + str3
print(str4)

Ответ: 121312141213121

Что покажет приведенный ниже фрагмент кода?

mystr = ‘123’ * 3 + ‘456’ * 2 + ‘789’ * 1
print(mystr)

Ответ: 123123123456456789

Напишите программу, которая выводит текст:

«Python is a great language!», said Fred. «I don’t ever remember having this much fun before.»

Примечание. Используйте конкатенацию строк.

a = '"Python is a great language!", said Fred. ' b = '"I don' c = "'t ever remember having this much " d = 'fun before."' print(a + b + c + d)

What’s Your Name?

Напишите программу, которая считывает с клавиатуры две строки – имя и фамилию пользователя и выводит фразу:

«Hello [введенное имя] [введенная фамилия]! You just delved into Python».

Формат входных данных
На вход программе подаётся две строки (имя и фамилия), каждая на отдельной строке.

Формат выходных данных
Программа должна вывести текст в соответствии с условием задачи.

Примечание. Между firstname lastname вставьте пробел =)

a = input() b = input() print("Hello", a, b+"!", "You just delved into Python")

Футбольная команда

Напишите программу, которая считывает с клавиатуры название футбольной команды и выводит фразу:

«Футбольная команда [введённая строка] имеет длину [длина введённой строки] символов».

Формат входных данных
На вход программе подаётся строка – название футбольной команды.

Формат выходных данных
Программа должна вывести текст в соответствии с условием задачи.

command = input() dlina = str(len(command)) print('Футбольная команда ' + command + ' имеет длину ' + dlina + ' символов')

Три города

Даны названия трех городов. Напишите программу, которая определяет самое короткое и самое длинное название города.

Формат входных данных
На вход программе подаётся названия трех городов, каждое на отдельной строке.

Формат выходных данных
Программа должна вывести самое короткое и длинное название города, каждое на отдельной строке.

Примечание. Гарантируется, что длины названий всех трех городов различны.

a = input() b = input() c = input() if min (len(a), len(b), len(c)) == len(a): print(a) elif min (len(a), len(b), len(c)) == len(b): print(b) else: print(c) if max (len(a), len(b), len(c)) == len(a): print(a) elif max (len(a), len(b), len(c)) == len(b): print(b) else: print(c)

Арифметические строки

Вводятся 3 строки в случайном порядке. Напишите программу, которая выясняет можно ли из длин этих строк построить возрастающую арифметическую прогрессию.

Формат входных данных
На вход программе подаются три строки, каждая на отдельной строке.

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

a = len(input()) b = len(input()) c = len(input()) if a + b + c == (min(a, b, c) + max(a, b, c))/2*3: print("YES") else: print("NO")

Какие значения может принимать строковая переменная s , чтобы в результате выполнения кода было выведено слово «YES»?

if s in ‘abc123abc’:
print(‘YES’)
else:
print(‘NO’)

Цвет настроения синий

Напишите программу, которая считывает одну строку, после чего выводит «YES», если в введенной строке есть подстрока «синий» и «NO» в противном случае.

Формат входных данных
На вход программе подается одна строка.

Формат выходных данных
Программа должна вывести текст в соответствии с условием задачи.

s = input() if 'синий' in s: print('YES') else: print('NO')

Отдыхаем ли?

Напишите программу, которая считывает одну строку, после чего выводит «YES», если в введённой строке есть подстрока «суббота» или «воскресенье», и «NO» в противном случае.

Формат входных данных
На вход программе подается одна строка.

Формат выходных данных
Программа должна вывести текст в соответствии с условием задачи.

s = input() if 'суббота' in s or 'воскресенье' in s: print('YES') else: print('NO')

Корректный email

Будем считать email адрес корректным, если в нем есть символ собачки (@) и точки. Напишите программу проверяющую корректность email адреса.

Формат входных данных
На вход программе подаётся одна строка – email адрес.

Формат выходных данных
Программа должна вывести строку «YES», если email адрес является корректным и «NO» в ином случае.

Примечание. Наличие символов @ и . недостаточно для корректности email адреса, однако их отсутствие гарантировано влечёт за собой неверный email.

str = input() if '@' in str and '.' in str: print('YES') else: print('NO')

Источник

Читайте также:  Css секция на всю страницу

What’s Your Name? in Python | HackerRank Solution

Hello coders, today we will be solving What’s Your Name? in Python Hacker Rank Solution.

What

Problem

You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:

Hello firstname lastname! You just delved into python.

Input Format

The first line contains the first name, and the second line contains the last name.

Constraints

The length of the first and last name ≤ 10.

Output Format

Print the output as mentioned above.

Sample Input 0

Sample Output 0

Hello Ross Taylor! You just delved into python.

Explanation

The input read by the program is stored as a string data type. A string is a collection of characters.

Solution – What’s Your Name in Python – Hacker Rank Solution

Python 3

def print_full_name(a, b): print("Hello " + a, b + "! You just delved into python.") if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)

Disclaimer: The above Problem (What’s Your Name) is generated by Hacker Rank but the Solution is provided by CodingBroz. This tutorial is only for Educational and Learning Purposes.

Источник

HackerRank Solution: Python What’s your name? [3 Methods]

You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:

Hello firstname lastname! You just delved into python. 

Function Description

  • Complete the print_full_name function in the editor below.
  • print_full_name has the following parameters:
    • string first: the first name
    • string last: the last name
    • Prints string: ‘ Hello firstname lastname! You just delved into python ‘ where and are replaced with first and last.

    Input Format:

    The first line contains the first name, and the second line contains the last name.

    Constraints:

    The length of the first and last names are each ≤ 10.

    Sample Input:

    Sample Output:

    Hello Ross Taylor! You just delved into python. 

    Explanation

    The input read by the program is stored as a string data type. A string is a collection of characters.

    Possible solutions

    Now we will see various solutions, to solve the problem given above. The following code is already given on the editor of the hacker rank:

    # Complete the 'print_full_name' function below. # # The function is expected to return a STRING. # The function accepts following parameters: # 1. STRING first # 2. STRING last # def print_full_name(first, last): # Write your code here if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)

    Let us now jump into solutions:

    Solution-1: Using <> brackets

    Let us now use the <> brackets to solve the problem:

    def print_full_name(first, last): # Write your code here print(f'Hello ! You just delved into python.') if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)

    This code defines a function called » print_full_name » which takes in two parameters, » first » and » last «, and uses them to create a string that says » Hello (first) (last)! You just delved into python. » using string formatting. The function then prints that string.

    The solution also includes an if statement that checks if the current script is being run as the main program (as opposed to being imported as a module into another program). If the current script is the main program, it prompts the user to input their first and last name, then calls the » print_full_name » function with the user’s input as the arguments, and prints the output.

    Solution-2: Using .format to print

    Now, we will use .format to print and solve the given problem:

    def print_full_name(first, last): # Write your code here print(f'Hello ! You just delved into python.') if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)

    This solution also provide exactly the same as the previous code you provided. The only difference is the last line of the if block, where the function call is missing the . at the end of the line. This means that the function will execute and output the string as expected, but it will not return any value and this value will not be assigned to any variable.

    Solution-3: Using + operators

    We can also use the + operator to connect strings together as shown below:

    def print_full_name(first, last): print("Hello " +first+" "+last+"! You just delved into python.") if __name__ == '__main__': first_name = input() last_name = input() print_full_name(first_name, last_name)

    This solution uses string concatenation to create and print a string that says «Hello (first) (last)». The code uses the «+» operator to join the string «Hello «, the variable «first», the string » «, the variable «last», and the string «.

    Summary

    In this short article, we discussed how we can solve «What’s your name?» problem on Hacker Rank. We solved the problem using three different methods and explained each one.

    Источник

Оцените статью