Last active
May 24, 2018 02:37
-
-
Save seven0525/0e281738fbec8d3ad41d33622bf5b14b to your computer and use it in GitHub Desktop.
「自作Python100本ノック」6日目(丸1日Python生活:26本〜30本目) ref: https://qiita.com/ahpjop/items/81d093623ae4125112c5
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 | |
#4 | |
things[2] = things[2].upper() | |
things[2] = things[2][::-1] | |
things[2] = things[2] |
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 | |
e2f = {"dog":"chien","cat":"chat","walrus":"mourse"} | |
e2f | |
#2 | |
e2f["walrus"] | |
#3 | |
f2e = {} | |
for english, french in e2f.items(): #辞書のすべての値を取得するには、items()を使う | |
f2e[french] = english | |
f2e | |
#4 | |
set(e2f.keys()) |
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 | |
life = {"animals":{ | |
"cats":["Henri","Grumpy","lucy"], | |
"dogs":{}, | |
"birds":{}}, | |
"plants":{}, | |
"other":{} | |
} | |
#2 | |
print(life.keys()) | |
#3 | |
print(life["animals"].keys()) | |
#4 | |
print(life["animals"]["cats"]) |
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
even = [number for number in range(50) if number % 2 == 0] | |
even |
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
squares = {key: key * key for key in range(50)} | |
squares |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment