본문 바로가기

전체 글

(1836)
Split Pairs Quiz> Split the string into pairs of two characters. If the string contains an odd number of characters, then the missing second character of the final pair should be replaced with an underscore ('_'). Input: A string. Output: An iterable of strings. Example: split_pairs('abcd') == ['ab', 'cd'] split_pairs('abc') == ['ab', 'c_'] Precondition: 0 1. a의 문자의 갯수를 변수에 할당한다. def split_pairs2(a): len_sp..
Max Digit Quiz> You have a number and you need to determine which digit in this number is the biggest. Input: A positive int. Output: An Int (0-9). Example: max_digit(0) == 0 max_digit(52) == 5 max_digit(634) == 6 max_digit(1) == 1 max_digit(10000) == 1 def max_digit(number: int) -> int: # your code here return 0 if __name__ == '__main__': print("Example:") print(max_digit(0)) # These "asserts" are used f..
Replace First Quiz> In a given list the first element should become the last one. An empty list or list with only one element should stay the same. example Input: List. Output: Iterable. Example: replace_first([1, 2, 3, 4]) == [2, 3, 4, 1] replace_first([1]) == [1] from typing import Iterable def replace_first(items: list) -> Iterable: # your code here return items if __name__ == '__main__': print("Example:")..
Remove All Before Quiz> Not all of the elements are important. What you need to do here is to remove from the list all of the elements before the given one. example For the illustration we have a list [3, 4, 5] and we need to remove all elements that go before 3 - which is 1 and 2. We have two edge cases here: (1) if a cutting element cannot be found, then the list shoudn't be changed. (2) if the list is empty, t..
Backward String Quiz> You should return a given string in reverse order. Input: A string. Output: A string. Example: backward_string('val') == 'lav' backward_string('') == '' backward_string('ohho') == 'ohho' backward_string('123456789') == '987654321' def backward_string(val: str) -> str: # your code here return None if __name__ == '__main__': print("Example:") print(backward_string('val')) # These "asserts" a..
End Zeros Quiz> Try to find out how many zeros a given number has at the end. Input: A positive Int Output: An Int. Example: end_zeros(0) == 1 end_zeros(1) == 0 end_zeros(10) == 1 end_zeros(101) == 0 def end_zeros(num: int) -> int: # your code here return None if __name__ == '__main__': print("Example:") print(end_zeros(0)) # These "asserts" are used for self-checking and not for an auto-testing assert en..
Number Length Quiz> You have a positive integer. Try to find out how many digits it has? Input: A positive Int Output: An Int. Example: number_length(10) == 2 number_length(0) == 1 def number_length(a: int) -> int: # your code here return None if __name__ == '__main__': print("Example:") print(number_length(10)) # These "asserts" are used for self-checking and not for an auto-testing assert number_length(10) ..
Acceptable Password I Quiz> You are the beginning of a password series. Every mission will be based on the previous one. Going forward the missions will become slightly more complex. In this mission you need to create a password verification function. Those are the verification conditions: the length should be bigger than 6. Input: A string. Output: A bool. Example: is_acceptable_password('short') == False is_accepta..