본문 바로가기

Python345

0910. Quarter of the year Given a month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number. For example: month 2 (February), is part of the first quarter; month 6 (June), is part of the second quarter; and month 11 (November), is part of the fourth quarter. Solution: def quarter_of(month): return (lambda x: x%3==0 and x//3 or x//3+1)(month) Other Solution: from math import cei.. 2022. 9. 10.
0909. Will there be enough space? The Story: Bob is working as a bus driver. However, he has become extremely popular amongst the city's residents. With so many passengers wanting to get aboard his bus, he sometimes has to face the problem of not enough space left on the bus! He wants you to write a simple program telling him if he will be able to fit all the passengers. Task Overview: You have to write a function that accepts t.. 2022. 9. 9.
0908. Sorted? yes? no? how? Complete the method which accepts an array of integers, and returns one of the following: "yes, ascending" - if the numbers in the array are sorted in an ascending order "yes, descending" - if the numbers in the array are sorted in a descending order "no" - otherwise You can assume the array will always be valid, and there will always be one correct answer. Solution: def is_sorted_and_how(arr): .. 2022. 9. 8.
0907. Count by X Create a function with two arguments that will return an array of the first n multiples of x. Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array or list ( depending on language ). Examples count_by(1,10) #should return [1,2,3,4,5,6,7,8,9,10] count_by(2,5) #should return [2,4,6,8,10] Solution: def get_range_index(f.. 2022. 9. 7.
0906. The Coupon Code Story Your online store likes to give out coupons for special occasions. Some customers try to cheat the system by entering invalid codes or using expired coupons. Task Your mission: Write a function called checkCoupon which verifies that a coupon code is valid and not expired. A coupon is no more valid on the day AFTER the expiration date. All dates will be passed as strings in this format: "MO.. 2022. 9. 6.
pytest _ pytest-cov로 coverage 확인하기(실습) GitHub - Daco2020/pytest-cov-practice: Repository for practicing pytest-cov Repository for practicing pytest-cov. Contribute to Daco2020/pytest-cov-practice development by creating an account on GitHub. github.com (실습에 사용하는 소스코드는 위 링크에서 확인할 수 있습니다.) pytest-cov 란? pytest-cov는 --cov 옵션 추가하여 테스트 대상의 coverage를 확인할 수 있습니다. 사용자는 coverage 수치를 통해 테스트의 적용범위를 파악할 수 있습니다. 실습 방법 레포지토리 복사 git clone https://g.. 2022. 9. 5.