大宮盆栽デイズ - Omiya Bonsai Days -

冗談めかす埼玉のファインマン

2019-10-12から1日間の記事一覧

@CheckiO@The Most Wanted Letter

def checkio(text: str) -> str: #replace this for solution import re letter = [] text = text.lower() for c in text: m = re.match(r'[a-z]', c) if m is None: continue else: letter.append(c) list_zero = [] set_letter = set(letter) length = len…

@CheckiO@Non-unique Elements

# Your optional code here # You can import some modules or create additional functions def checkio(data: list) -> list: # Your code here # It's main function. Don't remove this function # It's used for auto-testing and must return a result…

@CheckiO@House Password

def checkio(data: str) -> bool: # replace this for solution # return True or False import re if len(data) < 10: return False if not bool(re.search(r'[a-z]', data)): return False if not bool(re.search(r'[A-Z]', data)): return False if not b…

@CheckiO@Popular Words

def popular_words(text: str, words: list) -> dict: # 小文字に変換する lower_text = text.lower() # 改行(\n)をスペースに変換する replace_text = lower_text.replace('\n',' ') # 空白を区切りとして文字列をリストに変換する list_text = replace_t…

@CheckiO@Best Stock

def best_stock(data): value_sorted = sorted(data.items(), key=lambda x:x[1]) return value_sorted[-1][0] if __name__ == '__main__': print("Example:") print(best_stock({ 'CAC': 10.0, 'ATX': 390.2, 'WIG': 1.2 })) # These "asserts" are used fo…

@CheckiO@Correct Sentence

def correct_sentence(text: str) -> str: """ returns a corrected sentence which starts with a capital letter and ends with a dot. """ capital_letter = text.capitalize() capital_letter = capital_letter[0] + text[1:] if capital_letter.find('.…

@CheckiO@First Word

def first_word(text: str) -> str: """ returns the first word in a given text. """ # ドットとカンマをスペースに置換する del_conmma = text.replace(',', ' ') del_dot = del_conmma.replace('.', ' ') replaced_text = del_dot # スペースを区切りに…