1
0

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 -1

Last updated at Posted at 2018-04-19

from pprint import pprint
中身が見やすい

1129 + 2344 
>>> 3473

2800 * 1.08
>>> 3024.0

(40 + 50) * 3 -50
>>> 220
40 + 50  * 3 - 50
>>> 140 

255 % 3
>>> 0
255 % 7 
>>> 3

2 ** 3
>>> 8
5 ** 4
>>> 625

(4 + 5j) - (3 - 4j)
>>> (1 + 9j)
1j ** 2
>>> (-1 + 0j)

@ tax = 0.08
@ price = 120
price * tax 
>>> 9.6

'hunter' * 2
>>> hunterhunter

@ text = 'hello'
text.upeer()
>>> 'HEELO'

@ world = maintenance
world.count('n')
>>> 3

46 < 49
>>> True
46 > 49
>>> False

@ Agroup = ['kazz','gorou']
@ Agroup.append('dai')
Agroup
>>> ['kazz','gorou','dai']

@ Agroup = ['kazz','gorou','dai']
@ Agroup.sort()
aAgroup
>>> ['kazz','gorou','dai']

@ activities = ['monday' : 'mon', 'wednesday' : 'wed']
activities['monday']
>>> mon

@ activities.keys()
>>> dict_keys(['monday','wednesday'])

@ activities.values()
>>> dict_values(['mon','wed'])

@ candy = set('delicious')
print(candy)
>>> {'d','e','l','i','c','i','o','u','s'}

@ flavor = ['apple','pech','soda']
@ candy = set(flavor)
candy
>>> {'apple','pech','soda'}

@ canny.update(['grape'])
candy
>>> {'apple','pech','soda','grape'}

@ flavor_set_A = {'apple','pech','soda',}
@ flavor_set_B = {'apple','peach','choco'}
flavor_set_A - flavor_set_B
>>> {'peach'}
flavor_set_A & flavor_set_B
>>> {'apple','soda'}

@ age = 15
@ if (18 <= age):
    print('OK')
  else:
    print('NO')
>>> NO

@ age = 70
@ if (60<=age):
    print('aaa')
  elif (18<=age):
    print('bbb')
  else:
    print('ccc')
>>> aaa
@ pointcard = Ture
@ count = 5
(pointcard == Ture)
>>> Ture
(count == 5)
>>> Ture
((pointcard == Ture) and (count == 5))
>>> Ture

@ pointcard = False
@ count = 5
(pointcard == Ture)
>>> False
(count == 5)
>>> Ture
@ word = 'ninja'
@ for chara in word:
    print(chara)
>>>
n
i
n
j
a

@ music_list = ['rock','anime','pop']
@ for music in music_list:
   print('now playing...' + music)

>>>  now playing... rock
>>>  now palying... anime
>>>  now palying... pop

@ count = 0
@ while (count < 5):
    print(counter)
    counter = counter + 1
>>>
0
1
2
3
4

@ power = 2
@ while(Ture):
   print('aaa')
   print('bbb')
   print('ccc')
   power = power - 1
   if (power == 0):
      break
>>>
aaa
bbb
ccc
aaa
bbb
ccc

@ family = ['ryu-ko','mako','satsuki']
@ for kid in family:
   print('Hi !' + kid)
   print('OK')
   print('?')
   continue
>>>
Hi ! ryo-ko
OK
?
Hi ! mako
OK
?
Hi ! satsuki
OK
?

dic={}

dic['one'] = 'tennis'
dic['two'] = 'music'
dic['three'] = 'soccer'
print(dic)
# dic['listTeam'] = team

print(dic['one'])
print(dic['two'])
print(dic['three'])
# print(dic['listTeam'])

keys = dic.keys()
print(keys)

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

>>>

{'one': 'tennis', 'two': 'music', 'three': 'soccer'}
tennis
music
soccer
dict_keys(['one', 'two', 'three'])
tennis
music
soccer

from pprint import pprint
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']
dicmember={}
dicmember['1']='sato'
dicmember['2']='nao'
dicmember['3']='john'
dicmember['4']='lisa'
dicmember['5']='kaoru'
dicmember['6']='ryo'
dicmember['7']='bob'
dicmember['8']='jack'
dicmember['9']='mary'
dicmember['10']='linda'
dicmember['11']='yosuke'
dicmember['12']='takashi'
dicmember['13']='saori'
dicmember['14']='yuki'
dicmember['15']='tomo'
dicmember['16']='take'
dicmember['17']='yusuke'
dicmember['18']='nori'
dicmember['19']='mari'
dicmember['20']='sachi'
print(dicmember)

dicTotal = {}
for n in range(len(team)):
    dicmember[n] = team[n]
cnt = 0    
# print(dicmember)

keys = dicmember.keys()
# print(keys)
for key in keys:
    name = dicmember[key]
    if name in boss:
        smalldic={}
        smalldic['team']='boss'
        
        smalldic['name']=name
#        print(smalldic)
        dicTotal[cnt]=smalldic
        cnt = cnt + 1
pprint(dicTotal)

>>>

{'1': 'sato', '2': 'nao', '3': 'john', '4': 'lisa', '5': 'kaoru', '6': 'ryo', '7': 'bob', '8': 'jack', '9': 'mary', '10': 'linda', '11': 'yosuke', '12': 'takashi', '13': 'saori', '14': 'yuki', '15': 'tomo', '16': 'take', '17': 'yusuke', '18': 'nori', '19': 'mari', '20': 'sachi'}
{0: {'name': 'john', 'team': 'boss'},
 1: {'name': 'lisa', 'team': 'boss'},
 2: {'name': 'bob', 'team': 'boss'},
 3: {'name': 'jack', 'team': 'boss'},
 4: {'name': 'takashi', 'team': 'boss'},
 5: {'name': 'nori', 'team': 'boss'},
 6: {'name': 'mari', 'team': 'boss'},
 7: {'name': 'sachi', 'team': 'boss'},
 8: {'name': 'john', 'team': 'boss'},
 9: {'name': 'lisa', 'team': 'boss'},
 10: {'name': 'bob', 'team': 'boss'},
 11: {'name': 'jack', 'team': 'boss'},
 12: {'name': 'takashi', 'team': 'boss'},
 13: {'name': 'nori', 'team': 'boss'},
 14: {'name': 'mari', 'team': 'boss'},
 15: {'name': 'sachi', 'team': 'boss'}}
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)

>>>

vhello world
how are you?
Im fine
Im fine
Im fine
Im fine

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?