Skip to content

Instantly share code, notes, and snippets.

View seven0525's full-sized avatar

ahpjop seven0525

View GitHub Profile
@seven0525
seven0525 / q1.py
Last active May 29, 2018 07:51
「自作Python100本ノック」1日目(はじめに〜5本目) ref: https://qiita.com/ahpjop/items/373f807d68044cda1c9b
s = 0
for i in range(1,51):
s += i
print(s)
@seven0525
seven0525 / q10.py
Last active May 29, 2018 07:52
「自作Python100本ノック」2日目(6本〜10本目) ref: https://qiita.com/ahpjop/items/909fd55e48211dab2c5c
def j_hash(n):
s = str(n)
array = list(map(int, list(s)))
a = sum(array)
if n % a == 0:
print("Hashnumber")
else:
print("Not hashnumber")
j_hash(444)
@seven0525
seven0525 / notq11.py
Last active May 24, 2018 02:33
「自作Python100本ノック」3日目(11本〜15本目) ref: https://qiita.com/ahpjop/items/023cb561d7a2081ad606
def sort_text(text):
text = open(text).read().split()
aws = text.sort()
print(aws)
sort_text("number.txt")
@seven0525
seven0525 / q16.py
Last active September 28, 2019 18:29
「自作Python100本ノック」4日目(16本〜20本目) ref: https://qiita.com/ahpjop/items/c036a9dbc2f8b4a23c62
from math import sin,pi
print(sin(pi/4)) #piは180°を表す
@seven0525
seven0525 / q21.py
Last active May 24, 2018 02:36
「自作Python100本ノック」5日目(Googleサマーインターン選考問題受けてみた:20本〜25本目) ref: https://qiita.com/ahpjop/items/0dffbfbae7609329c5ca
def cal_patern(a,b,c,x):
count = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if 500 * i + 100 * j + 50 * k == x:
count += 1
return count
cal_patern(3,5,6,1500)
@seven0525
seven0525 / q26.py
Last active May 24, 2018 02:37
「自作Python100本ノック」6日目(丸1日Python生活:26本〜30本目) ref: https://qiita.com/ahpjop/items/81d093623ae4125112c5
#1
things = ["mozzarella","cinderella","salmonella"]
#2
things[0] = things[0].capitalize()
things
#3
things[1] = things[1].upper()
things
@seven0525
seven0525 / file4.txt
Last active May 24, 2018 02:40
「自作Python100本ノック」7日目(1週間の感想:31本〜40本目) ref: https://qiita.com/ahpjop/items/e852688b0e91eee50e00
#問題のコード
short_list = [1,2,3]
while True:
value = input("Position [q to qui]? ")
if value == "q":
break
positon = int(value)
print(short_list[position])
@seven0525
seven0525 / file8.txt
Last active June 3, 2018 14:55
「自作Python100本ノック」8日目(半年ぶりの運動:41本〜52本目) ref: https://qiita.com/ahpjop/items/170c7450604c00f37230
poetry = "We have seen thee, queen of cheese,
Lying quietly at your ease,
Gently fanned by evening breeze,
Thy fair form no flies dare seize.
All gaily dressed soon you'll go
To the great Provincial show,
To be admired by many a beau
In the city of Toronto.
@seven0525
seven0525 / file7.txt
Last active May 24, 2018 02:46
「自作Python100本ノック」9日目(53本〜62本目) ref: https://qiita.com/ahpjop/items/e206de89cf30b37476bc
##Q62: bookテーブルのtitle列を選択し、アルファベット順に表示せよ。
    
```q62.py
sql = "select title from book order by title asc"
for row in db.execute(sql):
print(row)
@seven0525
seven0525 / q63.py
Last active May 24, 2018 02:51
「自作Python100本ノック」10日目(63本〜70本目) ref: https://qiita.com/ahpjop/items/f92fe9fcd8f39cd44952
from datetime import date
now = date.today()
now_str = now.isoformat() #文字列の形にする
with open("today.txt", "wt") as outfile:
outfile.write(now_str)
now_str