This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = 0 | |
for i in range(1,51): | |
s += i | |
print(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sort_text(text): | |
text = open(text).read().split() | |
aws = text.sort() | |
print(aws) | |
sort_text("number.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sin,pi | |
print(sin(pi/4)) #piは180°を表す |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 | |
things = ["mozzarella","cinderella","salmonella"] | |
#2 | |
things[0] = things[0].capitalize() | |
things | |
#3 | |
things[1] = things[1].upper() | |
things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#問題のコード | |
short_list = [1,2,3] | |
while True: | |
value = input("Position [q to qui]? ") | |
if value == "q": | |
break | |
positon = int(value) | |
print(short_list[position]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Q62: bookテーブルのtitle列を選択し、アルファベット順に表示せよ。 | |
```q62.py | |
sql = "select title from book order by title asc" | |
for row in db.execute(sql): | |
print(row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date | |
now = date.today() | |
now_str = now.isoformat() #文字列の形にする | |
with open("today.txt", "wt") as outfile: | |
outfile.write(now_str) | |
now_str |
OlderNewer