2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python 基本コード練習

Last updated at Posted at 2018-04-19
1129+2344
3473
(40+50)*3-50
220
2**3
8
tax = 0.8
price = 120
suzuki_telephone = '090-1234 -5678'

price * tax
9.6
import keyword
key.kwlist
34 > 22
True
'thunder' + 'bolt'
'thunderbolt'
'hunter' * 2
'hunterhunter'
word = 'maintenane'
word.count('n')

3
Agroup = ['Kazu', 'Gosu']
Agroup.append('dai')
Agroup

['Kazu', 'Gosu', 'dai']
Agroup = ['Kazu', 'Gosu', 'dai']
Agroup.remove('dai')
Agroup

['Kazu', 'Gosu']
Agroup = ['Dai', 'Gosu', 'Kazu']
Agroup.sort()
Agroup

['Dai', 'Gosu', 'Kazu']

activites = {'Monday':'basuke', 'Tuesday':'zitensya', 'Wednesday':'keion'}

activites['Tuesday']

'zitensya'
activites = {'Monday':'basuke', 'Tuesday':'zitensya', 'Wednesday':'keion'}

activites.keys()

dict_keys(['Monday', 'Tuesday', 'Wednesday'])
activites = {'Monday':'basuke', 'Tuesday':'zitensya', 'Wednesday':'keion'}

activites.values()

dict_values(['basuke', 'zitensya', 'keion'])
flavor_list = ['mint', 'choco', 'strawberry', 'banana']
flavor_list[0] = 'ramurezon'
print(flavor_list)

['ramurezon', 'choco', 'strawberry', 'banana']
diary = {}
key = ('kamata', '08-01')
diary[key] = '70kg'
print(diary)

{('kamata', '08-01'): '70kg'}
flavor = {'apple', 'banana', 'soda'}
candy = set(flavor)
candy

{'apple', 'banana', 'soda'}
flavor = {'apple', 'banana', 'soda'}
candy = set(flavor)

candy.update(['grape'])
candy

{'apple', 'banana', 'grape', 'soda'}
flavor = {'apple', 'banana', 'soda'}
flavorb = {'apple', 'banana', 'choco'}

flavor - flavorb

{'soda'}
flavor = {'apple', 'banana', 'soda'}
flavorb = {'apple', 'banana', 'choco'}

flavor & flavorb

{'apple', 'banana'}
age = 29
if (60 <= age):
    print('sell ticket')
    
elif (18 <=age):
    print('sell sell ')
    
else:
    print('not sell')

sell sell 
pointcard = True
count = 5
if ((pointcard == True) and (count == 5)):
    print('arigato')

arigato
for count in range(3):
    print('chris')
    print(count)

chris
0
chris
1
chris
2
li = ['do','ro','ao','ho']

for momo in li:
    print('now ... ' + momo)

now ... do
now ... ro
now ... ao
now ... ho
co = 0
while(co < 5):
    print(co)
    co = co+1

0
1
2
3
4
li = ['do','ro','ao','ho']

for momo in li:
    print('now ... ' + momo)
    print('hetta')
    print('gohan')
    
    continue
    print('gogo')

now ... do
hetta
gohan
now ... ro
hetta
gohan
now ... ao
hetta
gohan
now ... ho
hetta
gohan
dic = {}

dic['one'] = 'tennis'
dic['two'] = 'music'
dic['three'] = 'soccer'

print(dic)

{'one': 'tennis', 'two': 'music', 'three': 'soccer'}
team=['sato','nao','john','lisa','kaoru','ryo','bob','jack','mary','linda','yosuke','takashi','saori', 'yuki','tomo', 'take','yusuke','nori','mari','sachi']

boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']

dic = {}

dic['one'] = 'tennis'
dic['two'] = 'music'
dic['three'] = 'soccer'

dic['listTeam'] = team



print(dic['listTeam'][2])


john
team=['sato','nao','john','lisa','kaoru','ryo','bob','jack','mary','linda','yosuke','takashi','saori', 'yuki','tomo', 'take','yusuke','nori','mari','sachi']

boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']

dic = {}

dic['one'] = 'tennis'
dic['two'] = 'music'
dic['three'] = 'soccer'

dic['listTeam'] = team
keys = dic.keys()


print(keys)

dict_keys(['one', 'two', 'three', 'listTeam'])
team=['sato','nao','john','lisa','kaoru','ryo','bob','jack','mary','linda','yosuke','takashi','saori', 'yuki','tomo', 'take','yusuke','nori','mari','sachi']

boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']

dic = {}

dic['one'] = 'tennis'
dic['two'] = 'music'
dic['three'] = 'soccer'

dic['listTeam'] = team
keys = dic.keys()

for key in keys:
    print(dic[key])

tennis
music
soccer
['sato', 'nao', 'john', 'lisa', 'kaoru', 'ryo', 'bob', 'jack', 'mary', 'linda', 'yosuke', 'takashi', 'saori', 'yuki', 'tomo', 'take', 'yusuke', 'nori', 'mari', 'sachi']
def show():
    print('hello world')
    
def say(word):
    print(word)
    
def answer(word, n):
    for cnt in range(n):
        print(word)

show()
say('how are you?')
answer('im fine',4)

hello world
how are you?
im fine
im fine
im fine
im fine
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?