• 検索結果がありません。

˜b”tx raw_input() q input() qMO :›–M‡b{² x È»› ˜b”qVt–M|™ x :‹› ˜b”qVt–M‡b

N/A
N/A
Protected

Academic year: 2021

シェア "˜b”tx raw_input() q input() qMO :›–M‡b{² x È»› ˜b”qVt–M|™ x :‹› ˜b”qVt–M‡b"

Copied!
8
0
0

読み込み中.... (全文を見る)

全文

(1)

10 ©”Ø”ÅT’wÔ»w ˜

10 ©”Ø”ÅT’wÔ»w ˜

©”Ø”ÅT’Ö—`h È•:‹t ao|Óé¬åÜwAL›!=^d”Ä›ßQ‡b{©”Ö—›

˜b”tx raw_input() q input() qMO :›–M‡b{² x È»› ˜b”qVt–M|™ x :‹› ˜b”qVt–M‡b

*4

{ÍwÑ• ç›^loîæ`oˆ‡`•O•

• Ñ• çÊ• input1.py

1

# -* - coding : utf -8 -* -

2

3

namae = r a w _ i n p u t ( ’

KshxmpbT••

’)

4

print ’

\œtjx

’, namae , ’

Íp^lhÑ• ç›îæb”q|Íw‘Os¯ÔUZ‡b•

1

u s e r @ d e b i a n :~/ Desktop / d a t a p r o c 1 $ python input1 . py

2 K s h x i • p b T• •

f\p|ô-V qÖ—`o Enter ©”›!dy

1 \ œ t j x ô -V ^ œ

qZ—^•‡b{ÍwÓé¬åÜxÍw qpîæ^•‡`h•

1. ®Kshxi•pbT••¯qhØt¯Ô 2. !: namae ›^R{©”Ø”ÅÖ—›4m{

3. Ö—^•h È›!: namae tEÖ 4. ®\œtjx~~~¯›hØt¯Ô

\\pOAs:x| raw_input() pÖ—^•h È»x!: namae t¨ò^•”\qpb{

Ö—b”‹wU:‹pK”Ôùtx input() :›–M‡b{©”Ö—›!ZÇZo|Ö—`h:‹w ЛZ—b”Óé¬åÜ›^loˆ‡b{

• Ñ• çÊ• input2.py

1

# -* - coding : utf -8 -* -

2

3

num = input( ’

:‹›Ö—`oXi^M•

’)

4

print ’

Ö—^•h:‹w Ðx

’, num **2 , ’

pb

\•›îæb”qÍw‘Ots“‡b•

1

u s e r @ d e b i a n :~/ Desktop / d a t a p r o c 1 $ python input2 . py

2 :‹›Ö—` o X i ^ M•

1 2 3

3 Ö—^ • h:‹w Ðx

15129

p b

ÍwËm›ù˜doÍw‘Os BMI ›-‰b”Óé¬åÜ›^loˆ‡`•O•

• Ñ• çÊ• bmi1.py

1

# -* - coding : utf -8 -* -

2

3

namae = r a w _ i n p u t ( ’

Kshwʲ›Ö—`oXi^M•

’)

4

shintyo = input(’

Kshw Õx?·ï½pbT••

’)

*4Python3pxraw input()x -^•o|input()t”Võ˜“‡`h{

(2)

5

weight = input(’

Kshw.Ox?©é¬åÜpbT••

’)

6

bmi = 10000* weight /( shintyo **2)

7

print namae , ’

^œw " x

’, bmi , ’

pb

’ Óé¬åÜ›îæ`o×üw BMI ›-‰`oˆ‡`•O{

11 æg qz±

:¶px|Y`MËJx | §lhËJxPpK”qMM‡b{ Python p‹ P‹qMO‹wUK“|

ÚEUY`MTrOTp ~Pw‹U>‡“‡b{\•’xÚEt aorg›!=^d”qVt–M‡b{

Python px True |P› False p¯`‡b{\•’x'ÿ pK“› s™¯›Ëj‡b{ Ot«

™`sU’| ï»å«ÂŸÒ³£çpw«›_oXi^M•

1

>>> a = 3 # a

t

3

›EÖ 2

>>> a == 3 # a

x

3

i – O T

3

True # a ==3

xY` M

4

>>> a == 2 # a

x

2

i – O T• 5

False # a ==2

xY` X s M 6

>>> a > 2

7

True

8

>>> 3 != 2 # 3

x

2

ts` X s M i – O T• 9

True # 3

q

2

xŸs ” w p|ÍwÚEx

\w«w‘Ot|Ëmw:‹›z±`o TPTwÚE›Ð‚”ÄUpV‡b{Íw«p° ==, >, != ±qM OGø›;M‡`h{\•’xÔ»›z±b”qVt;M”wpz± ‰ qzy•oM‡b{:‹t0`

o–Q”–Q”z± ‰ txÍUK“‡b•

:‹t0`o–Q”z± ‰

✓ ✏

== != < > <= >=

\•’x|f•g•;w$s:¶Gø =, 6=, <, >, ≤, ≥ t0 `oM‡b{

✒ ✑

Æsøqsøwqjxó w ”less than or equal” wqjq‰aiq1Q‡`•O{ ° != ±x ”not equal” q1 Q‡b{

True q False txæg ‰ and, or, not ›æO\qUZR‡b{

1

>>> a = True # a

T r u e

q b ” 2

>>> b = False # b

F a l s e

q b ” 3

>>> a and b # a

T m

b

x• 4

False

5

>>> a or b # a

‡ h x

b

x 6

True

7

>>> not a # a

wq x• 8

False

Ô»U)Q’•hqVt|f•’w t0`o P‹›˜”\qUZR‡b{

æµÄ•Bùsr¯è«³ãït0`o–Q”z± ‰ ‹K“‡b•

✓ ✏

(3)

12 ÚEü0

1

>>> a = [3 ,6 ,5 ,1] # a

› æ µ Ä

[3 ,6 ,5 ,1]

q b ” 2

>>> 5 in a # 5

x

a

w¤t M ” i – O T• 3

True

4

>>> 7 in a # 7

x

a

w¤t M ” i – O T• 5

False

Íw‘Ot`o| ›Ð‚” type qʈù˜do–O\q‹ZR‡b•

1

>>> a = [3 ,5 ,6 ,1]

2

>>> type ( a )

3

<type ’ list ’>

4

>>> type ( a ) == list

5

True

6

>>> type ( a ) == tuple

7

False

12 ÚEü0

12.1 if

ÚE (True T False) t ao|rg›!=^d”qVt if qMO>Š’•h O›;M‡b{ if w qxÍw½ß”Äwè“pb•

A

A❋✪

✍✁X

A❋✂

\•› Python pxÍw Op{V‡b•

(4)

Python pw if wÏ

✓ ✏

1

if

ÚE

A :

2

[

rg

X ]

3

[

rg

X ]

4

[

rg

X ]

• ÚE A U True pK•yrg X U昕| False pK•yrg X x昕‡dœ{

• if wæwæ¤w¯éï°•±›h•ct‚

• rg X :æt˜h”Ôùx|Íw‘Ot ïÃïÄ› Q”{

✒ ✑

\\prg X w²w ïÃïÄ¢È<[£U OÍOAsþ›Lh`‡b{rg X U:æt˜h”qVt|

r\‡pUrg X pK”Tx ïÃïÄt‘loQ…^•‡b{ ïÃïÄxos”µÖ”µp_QsMw pbU| ïÃïÄU lhæüU|rg^•”Óé¬åÜwt¢Òé¿«£pK”qQ…^•‡b•

if A:

X

if ›–lh«J›•loˆ‡`•O{Íwžç°æ¶Ü› Python Óé¬åÜt`‡b{

(1) T: a ›Ö—^d”{

(2) a Uî:s’| ° a is even ±qÓæïÄ`oT’| a ›Rütb”{

(3) a U-:s’?‹`sM{

Ñ• çÊ• if1.py

1

# -* - coding : utf -8 -* -

2

a = input(’ Input integer a : ’)

3

4

if a %2 == 0: #

‹ `

a

Uî:s ’

5

print ’a is even ’

6

a = a /2 # a

R üt b ”{æw ï Ã ï Ä xOA‚ ‚ ‚

7

8

print a # a

w‹› Ó æ ï Ä

ÍwÓé¬åÜw 4 6 æèU if pb{îæ`oMXmTw:‹›Ö•oˆ^›¼`oˆ‡`•O{

12.2 if-else

Ít|—`óvsÚEü0›ßQ‡b{ÚEU wqVtxrg X |PwqVtx wrg Y U`hMq

`‡`•O{

(5)

12.2 if-else 12 ÚEü0

A

A❋✪

✍✁X

A❋✌

✂ ✄Y

if A:

X

else:

Y

‹j–œ|\•xÍp†Ì`h if iZp{X\qUpV‡b{m‡“

1

if

ÚE

A : #

ÚE

A

U s ’

2 rg

X #

rg

X

›æM|Ps ’æ˜ s M{ 3

if not

ÚE

A : #

ÚE

A

UPs ’

4 rg

Y # Y

æM|f O p s Z • yæ˜ s M{

q{XiZpb{`T`|Ít†Ìb” if-else ›–lo|‘“ÌÔ$t{X\q‹pV‡b{

Python pw if-else

✓ ✏

1

if

ÚE

A :

2 rg

X

3

else :

4 rg

Y

• ÚE A U True pK•y|rg X UæM| False pK•yrg Y ›æO{

• \\p‹rg X, rg Y x ïÃïÄt‘loQ…^•‡b{

✒ ✑

if-else ›–lh«J›•loˆ‡`•O{Íwžç°æ¶Ü›ßQ‡b{

(1) T: a ›Ö—^d”{

(2) ‹` a Uî:s’y| a ›Rütb”{

(3) ‹` a U-:s’y| a 3*a+1 tb”

(4) a w‹›¯Ôb”{

\•›Óé¬åÜp{Moˆ‡`•O{

• Ñ• çÊ• if2.py

1

# -* - coding : utf -8 -* -

2

a = input(’a ?: ’ )

3

4

if a %2 == 0: #

‹ `

a

Uî:s ’

5

a = a /2 # a

R üt b ”

6

else : #

f O p s Z • y

(6)

7

a = 3* a + 1 # a

3 a +1

t b ” 8

9

print a # a

w‹› Ó æ ï Ä

\wÓé¬åÜ›îæ`oMXmTw:‹›Ö•oˆ^›¼`oˆ‡`•O{

12.3 if-elif-else

^’tÚEü0›G\b”hŠtx if-elif-else ›–M‡b{ elif x else if wtpb{

if-elif-else

✓ ✏

1

if

ÚE

A :

2 rg

X

3

elif

ÚE

B :

4 rg

Y

5

else :

6 rg

Z

• ÚE A U wÔùtrg X ›æM‡b{

• ÚE A UPpÚE B U True wqVt|rg Y ›æM‡b{

• ÚE A ‹ÚE B ‹R“qhsMqVt|rg Z ›æM‡b{

• ^’tÚE C |ÚE D | ~~~qÚEU XÔùx elif prg`‡b{

✒ ✑

A

A❋✪

✍✁X

A❋✌

✍ ✁Y

B

✂✄B☎ ✆

B❋✌

✍✁Z

if A:

X

elif B:

Y

else:

Z

^’t elif ›åC`o| if-elif-elif-elif-else w‘OtÚE›ÿ•b\qUpV‡b{

12.4 óvs if w«

if-elif-else ›–lo|)Qhb¹UÞåTrOT›Q b”Óé¬åÜ›^“hM{¬è°æ¢µ¹

(7)

13 Å6ðJ

• hi`b¹åU 4 p“~•| 100 p‹Â“~•”åp‹ 400 p“~•”åxÞåqb”{

ÍwÞåw ŠMw ·tx| °hi`±U XKlo|ægÏ U˜T“tXX|fw‡‡pxÓé¬å Ütx`n’M{f\pÞåwÚE›Íw‘Ot{VÚ`‡b•

1. b¹åU 400 p“~•”s’y|f•xÞåpK”{

2. ÍŽŽwqV|b¹åx 100 p“~•”s’y|f•xÞåpxsM{

3. ÍŽŽwqV|b¹åU 4 p“~•”s’y|f•xÞåpK”{

4. Íwr•t‹pox‡’sMqV|fwåxÞåpxsM{

\•›îqb” Python wÓé¬åÜxÍw‘Ots“‡b{

• Ñ• çÊ• uruuQ.py

1

# -* - coding : utf -8 -* -

2

year = input( ’

b¹›Ö—

: ’) #

Ö` h:!:

y e a r

tEÖb ” 3

4

if year % 400 == 0: #

‹ `

y e a r

4 0 0

pÂl h(“ U

0

s ’ 5

print year , ’

xÞåpb{

6

elif year % 100 == 0: #

f O p s M q V|‹ `

y e a r

U

1 0 0

p“~• h ’ 7

print year , ’

xÞåpxK“‡dœ{

8

elif year % 4 == 0: #

f O p s M q V|‹ `

y e a r

U

4

p“~• h ’ 9

print year , ’

xÞåpb{

10

else : #

Íw¶o wÚEtpo x ‡ ’ s M q V 11

print year , ’

xÞåpxK“‡dœ{

13 Å6ðJ

13.1 ðJ• BMI -‰Óé¬åÜ

ʲ| Õ|.O›Ö—^d|f\T’ BMI ›-‰~¯Ô`|fw‹t ao•d~‚¬SwAL›Zb Óé¬åÜ›^“hM{Óé¬åÜxÍw q›æO‹wqb”{

(1) ʲ›Ö—^d|!:Ê namae tEÖ

(2) Õ~.O›Ö—^d|f•g• shintyo, weight tEÖ (3) bmi ›¯Ô

(4) ‹` bmi<18.5 s’| ®•d>¯pb¯q¯Ô

(5) fOpsMqV| bmi<25.0 s’| ®~mOpb¯q¯Ô (6) fOpsMqV| bmi<30 s’| ® “>¯pb¯q¯Ô (7) OQwrj’p‹sMqV® “bWpb¯q¯Ô

Íw qUîæ^•”‘Ot|mWwÓé¬åÜw° ***** ±wæü›* `oÓé¬åÜ›ìR^ds^M{

• Ñ• çÊ• bmi2.py

1

# -* - coding : utf -8 -* -

2

3

namae = r a w _ i n p u t ( ’

Kshwʲ›Ö—`oXi^M•

’)

4

shintyo = input(’

Kshw Õx?·ï½pbT••

’)

5

weight = input(’

Kshw.Ox?©é¬åÜpbT••

’)

6

7

bmi = 1 0 0 0 0 . 0 * weight /( shintyo **2)

(8)

8

bmi = round( bmi ,1) # b m i

w::Ž<

2

;è› úÖb ” 9

10

print namae , ’

^œw " x

’, bmi , ’

p

’ ,

11

12

if * * * * * * * * * * :

13

***** ’

•d>¯pb{

14

elif * * * * * * * * * * :

15

***** ’

~mOpb{

16

* * * * * * * * * * * * * * * :

17

***** ’

“>¯pb{

18

****:

19

***** ’

“bWpb{

参照

関連したドキュメント

Two Steiner triple systems (X, A) and (X, B) are said to intersect in m pairwise disjoint blocks if |A ∩ B| = m and all blocks in A ∩ B are pairwise disjoint... are said to intersect

If k is larger than n, the dimension of M , then B k (M) is equiva- lent to the normal homotopy type of M : Two manifolds have the same (= fibre homotopy equivalent) normal k-type

The following question arises: it is true that for every proper set ideal J of subsets of S there exists an invariant mean M on B(S, R ) for which elements of J are zero sets (J ⊂ J

Laplacian on circle packing fractals invariant with respect to certain Kleinian groups (i.e., discrete groups of M¨ obius transformations on the Riemann sphere C b = C ∪ {∞}),

The main purpose of this paper is to establish new inequalities like those given in Theorems A, B and C, but now for the classes of m-convex functions (Section 2) and (α,

We study the classical invariant theory of the B´ ezoutiant R(A, B) of a pair of binary forms A, B.. We also describe a ‘generic reduc- tion formula’ which recovers B from R(A, B)

Let us denote by hΣ n b| ♮,⊕ the smallest subcategory of Ho(M) which contains the object Σ n b and which is stable under taking desuspensions, fibers of morphisms, direct factors,

Given a sequence of choices of tentative pivots and splitting vertices, we obtain a matching M of by taking the union of all partial matchings M(A, B, p) performed at the