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

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

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

@CheckiO@Between Markers

答えを出すまでに時間がかかっています。それでも、考えているときは楽しく、(とりあえず)解決コードができたらうれしい気持ちになります。 ◆ ◆ ◆ 時間がかかる、という点でセンスが無いようにも思います。一方で、時間がかかっても粘って取り組むことがで…

@CheckiO@First Word (simplified)

def first_word(text: str) -> str: """ returns the first word in a given text. """ # your code here # return text[0:2] word = '' for c in text: if not c == ' ': word = word + c else: break return word if __name__ == '__main__': print("Examp…

@CheckiO@Between Markers (simplified)

def between_markers(text: str, begin: str, end: str) -> str: """ returns substring between two given markers """ index_begin = text.find(begin) index_end = text.find(end) return text[index_begin+1:index_end] if __name__ == '__main__': prin…

@CheckiO@Multiply (Intro)

def mult_two(a, b): return a * b if __name__ == '__main__': print("Example:") print(mult_two(3, 2)) # These "asserts" are used for self-checking and not for an auto-testing assert mult_two(3, 2) == 6 assert mult_two(1, 0) == 0 print("Codin…

@CheckiO@Second Index

def second_index(text: str, symbol: str) -> [int, None]: """ returns the second index of a symbol in a given text """ index = text.find(symbol) if index != -1: # findの第二引数で検索を開始する位置を指定できる。 index = text.find(symbol, in…

@CheckiO@Say Hi

# 1. on CheckiO your solution should be a function # 2. the function should return the right answer, not print it. def say_hi(name: str, age: int) -> str: """ Hi! """ introduces = "Hi. My name is " + name + " and I'm " + str(age) + " years…

@CheckiO@Bigger Price

def bigger_price(limit: int, data: list) -> list: """ TOP most expensive goods """ length = len(data) for i in range(length): for j in range(i, length): if data[j]['price'] > data[i]['price']: tmp = data[i] data[i] = data[j] data[j] = tmp …