본문 바로가기

Python345

Highest Scoring Word Given a string of words, you need to find the highest scoring word. Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc. You need to return the highest scoring word as a string. If two words score the same, return the word that appears earliest in the original string. All letters will be lowercase and all inputs will be valid. Solution: def high.. 2022. 7. 28.
Simple Fun #176: Reverse Letter Task Given a string str, reverse it and omit all non-alphabetic characters. Example For str = "krishan", the output should be "nahsirk". For str = "ultr53o?n", the output should be "nortlu". Input/Output [input] string str A string consists of lowercase latin letters, digits and symbols. [output] a string Solution: def reverse_letter(string): return ''.join([char for char in string[::-1] if char.. 2022. 7. 27.
Money, Money, Money Mr. Scrooge has a sum of money 'P' that he wants to invest. Before he does, he wants to know how many years 'Y' this sum 'P' has to be kept in the bank in order for it to amount to a desired sum of money 'D'. The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly. After paying taxes 'T' for the year the new sum is re-invested. Note to Tax: not the invested principal is taxed.. 2022. 7. 26.
Calculate BMI Write function bmi that calculates body mass index (bmi = weight / height2). if bmi 25 and "Overweight") \ or (bmi > 18.5 and "Normal") \ or "Underweight" 2022. 7. 25.
websockets _ Python 으로 비트코인 실시간 시세 가져오기 (feat. twelvedata) 주식이나 암호화폐는 실시간으로 거래가 이루어지기 때문에 시세 변동 또한 실시간으로 이루어진다. 때문에 정확한 정보를 고객에게 전달하기 위해서는 시장의 실시간 데이터를 가져와 가공 및 분석하여 고객에게 제공할 수 있어야 한다. 이번 글에서는 누구나 쉽게 따라할 수 있는, Python과 websockets으로 비트코인 시세 가져오기를 구현해보겠다. twelvedata 먼저 데이터를 어디서 가져올지 정해야하는데 이 글에서는 twelvedata를 사용하겠다. twelvedata는 재무데이터를 제공해주는 여러 곳 중 하나인데, 공식문서가 비교적 쉽게 설명되어있고 웹소켓을 간단히 테스트할 수 있는 웹페이지도 제공해주기 때문에 초보자가 접근하기 쉽다. 참고로 무료 계정에서는 최대 8개의 심볼(종목)을 수신받을 수 있.. 2022. 7. 24.
Check the exam The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers. The two arrays are not empty and are the same length. Return the score for this array of answers, giving +4 for each correct answer, -1 for each incorrect answer, and +0 for each blank answer, represented as an empty string (in C the space characte.. 2022. 7. 24.