Skip to content

Instantly share code, notes, and snippets.

@seven0525
Last active May 24, 2018 02:37
Show Gist options
  • Save seven0525/0e281738fbec8d3ad41d33622bf5b14b to your computer and use it in GitHub Desktop.
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
#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]
#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())
#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"])
even = [number for number in range(50) if number % 2 == 0]
even
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