テキスト。

 

 

自分のノートなので…

 

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 224-224/100
221.76

割り算。


>>> 224-224//100
222


//…小数点以下切り捨ての割り算
÷÷ とは書かない



>>> 224%100
24
%…「あまり」


>>> 224-224//100*100
24
このあまりの計算を簡素化できる。

>>> 2**3
8
階乗。2の3乗。2^3

>>> 2**4
16
2の4乗


>>> 8**(1/3)
2.0
3√8

>>> 2**(1/2)
1.4142135623730951
√2


>>> 'hello'
'hello'
>>> "hello"
'hello'
>>> print 'hello"
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello")?
>>> print 'hello'
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello')?
>>> print 'hello'
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello')?
>>> print ("helo")
helo
>>> peinr("hello")
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    peinr("hello")
NameError: name 'peinr' is not defined
>>> print ("hello")
hello
>>> print ('number','is',3*5)
number is 15
>>> print ('a','b','c','d','e','…という感じで可変長引数')
a b c d e …という感じで可変長引数

>>> print ('a','b','c', sep='/')
a/b/c
sep=で区切り文字を指定できる

>>> print ('a',end='@')
a@
>>> print ('a',end='? ')
a? 
>>> print ('a',end='@') print ('a',end='@') print ('a',end='@')
SyntaxError: invalid syntax
>>> print ('a',end='@'):print ('a',end='@'):print ('a',end='@')
SyntaxError: illegal target for annotation
>>> print ('a',end='@')
a@
>>> print ('a',end ='? ')
a? 

>>> len ('hello')*2
10
len…文字列長さ
数値扱いとなり2倍できる

>>> len ('hello')
5
文字列5
>>> 

 

毎日ちょっとずつ進めなくてはね。。。

 

※↑本来は、テキストでは

>>>print(len('hello'))

として、len関数の結果をprint関数の引数にできるよ、ということが書かれているのだけど、言うこときいてないね。

セゾンパール・アメリカン・エキスプレス(R)・カード

プレミアムウォーター