본문 바로가기

Python_Matter/Solve

Python Learn the basics Quiz 53

반응형

Q>

"For centuries, left-handers have suffered unfair discrimination in a world designed for right-handers." 

("수세기 동안, 왼손잡이는 우완 투수를 위해 설계된 세계에서 불공정 한 차별을 겪었습니다.")
Santrock, John W. (2008).

Motor, Sensory, and Perceptual Development.

(모터, 감각 및 지각 발달.)

"Most humans (say 70 percent to 95 percent) are right-handed, a minority (say 5 percent to 30 percent) are left-handed, and an indeterminate number of people are probably best described as ambidextrous."

("대부분의 인간은 (70-95 %) 우타자이며, 소수 민족 (5-30 %)이 왼손잡이이며, 불확실한 사람들이 아마 양손 잡이라고 묘사됩니다.")
Scientific American.

www.scientificamerican.com

One of the robots is charged with a simple task: to join a sequence of strings into one sentence to produce instructions on how to get around the ship.

(로봇 중 하나는 간단한 작업을 요구받습니다. 문자열 시퀀스를 한 문장으로 결합하여 배를 타는 방법에 대한 지침을 생성합니다.)

But this robot is left-handed and has a tendency to joke around and confuse its right-handed friends.

(그러나 이 로봇은 왼손잡이이며 우회적 인 친구들을 농담으로 혼란에 빠뜨리는 경향이 있습니다.)

You are given a sequence of strings.

(일련의 문자열이 주어집니다.)

You should join these strings into chunk of text where the initial strings are separated by commas.

( 이 문자열을 쉼표로 구분하여 텍스트 문자열에 결합해야합니다.)

As a joke on the right handed robots, you should replace all cases of the words "right" with the word "left", even if it's a part of another word.

(오른 손잡이 로봇에 대한 농담처럼 다른 단어의 일부인 경우에도 "오른쪽"이라는 단어의 모든 사례를 "왼쪽"이라는 단어로 바꿔야합니다.)

All strings are given in lowercase.

(모든 문자열은 소문자로 표시됩니다.)

 

Input: A sequence of strings as a tuple of strings (unicode).

         (문자열의 튜플 (유니 코드)의 문자열 시퀀스입니다.)

 

Output: The text as a string.

           (텍스트를 문자열로 나타냅니다.)

 

Example:

left_join(("left", "right", "left", "stop")) == "left,left,left,stop"
left_join(("bright aright", "ok")) == "bleft aleft,ok"
left_join(("brightness wright",)) == "bleftness wleft"
left_join(("enough", "jokes")) == "enough,jokes"

 

How it is used: This is a simple example of operations using strings and sequences.

                     (이것은 문자열 및 시퀀스를 사용하는 간단한 작업의 예입니다.)

 

Precondition: 0 < len(phrases) < 42

 

A>

def left_join(phrases):
    """
        Join strings and replace "right" to "left"
    """
    # replace : 문자열 변경 메소드
    # , 를 구분자로 모두 join 하여 문자를 변경
    return (','.join(phrases)).replace('right', 'left')

if __name__ == '__main__':
    print('Example:')
    print(left_join(("left", "right", "left", "stop")))

    # These "asserts" using only for self-checking and not necessary for auto-testing
    assert left_join(("left", "right", "left", "stop")) == "left,left,left,stop", "All to left"
    assert left_join(("bright aright", "ok")) == "bleft aleft,ok", "Bright Left"
    assert left_join(("brightness wright",)) == "bleftness wleft", "One phrase"
    assert left_join(("enough", "jokes")) == "enough,jokes", "Nothing to replace"
    print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")

 

O>

Example:
left,left,left,stop
Coding complete? Click 'Check' to review your tests and earn cool rewards!

Process finished with exit code 0

 

S>

https://py.checkio.org/

반응형

'Python_Matter > Solve' 카테고리의 다른 글

Python Learn the basics Quiz 55  (0) 2019.06.11
Python Learn the basics Quiz 54  (0) 2019.06.11
Python Learn the basics Quiz 52  (0) 2019.06.11
Python Learn the basics Quiz 51  (0) 2019.06.11
Python Learn the basics Quiz 50  (0) 2019.06.10