본문 바로가기

Python345

0127. Remove the time You're re-designing a blog and the blog's posts have the following format for showing the date and time a post was made: Weekday Month Day, time e.g., Friday May 2, 7pm You're running out of screen real estate, and on some pages you want to display a shorter format, Weekday Month Day that omits the time. Write a function, shortenToDate, that takes the Website date/time in its original string for.. 2023. 1. 28.
0126. Over The Road Task You've just moved into a perfectly straight street with exactly n identical houses on either side of the road. Naturally, you would like to find out the house number of the people on the other side of the street. The street looks something like this: Street 1| |6 3| |4 5| |2 you Evens increase on the right; odds decrease on the left. House numbers start at 1 and increase without gaps. When .. 2023. 1. 27.
0125. Counting sheep... Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [True, True, True, False, True, True, True, True , True, False, True, False, True, False, False, True , True, True, True, True , False, False, True, True] The correct answer would be 17. Hint: Don't forget to .. 2023. 1. 25.
0124. Regular Ball Super Ball Create a class Ball. Ball objects should accept one argument for "ball type" when instantiated. If no arguments are given, ball objects should instantiate with a "ball type" of "regular." ball1 = Ball() ball2 = Ball("super") ball1.ball_type #=> "regular" ball2.ball_type #=> "super" Solution: class Ball(object): def __init__(self, type: str = "regular") -> None: self._type = type @property def ba.. 2023. 1. 24.
0123. Check same case Write a function that will check if two given characters are the same case. If either of the characters is not a letter, return -1 If both characters are the same case, return 1 If both characters are letters, but not the same case, return 0 Examples 'a' and 'g' returns 1 'A' and 'C' returns 1 'b' and 'G' returns 0 'B' and 'g' returns 0 '0' and '?' returns -1 Solution: def same_case(a: str, b: s.. 2023. 1. 23.
0122. The Feast of Many Beasts The Feast of Many Beasts All of the animals are having a feast! Each animal is bringing one dish. There is just one rule: the dish must start and end with the same letters as the animal's name. For example, the great blue heron is bringing garlic naan and the chickadee is bringing chocolate cake. Write a function feast that takes the animal's name and dish as arguments and returns true or false .. 2023. 1. 23.