| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Python if for」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
 
1行目: 1行目:
==Pythoni if for==
+
==[[Python]]i if for==
 
[[Python]] |  
 
[[Python]] |  
[[http://python.secsup.org/?p=44 Python Osmosis]] |
+
[http://python.secsup.org/?p=44 Python Osmosis]
 
===if,for===
 
===if,for===
  
10行目: 10行目:
 
     Personal firewall software may warn about the connection IDLE
 
     Personal firewall software may warn about the connection IDLE
 
     makes to its subprocess using this computer's internal loopback
 
     makes to its subprocess using this computer's internal loopback
     interface.  This connection is not visible on any external
+
     interface.  This connection is not [[vi]]sible on any external
 
     interface and no data is sent to or received from the Internet.
 
     interface and no data is sent to or received from the Internet.
 
     ****************************************************************
 
     ****************************************************************

2020年2月16日 (日) 04:31時点における最新版

Pythoni if for

Python | Python Osmosis

if,for

Python 2.6.3 (r263rc1:75186, Oct  2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    
IDLE 2.6.3      
>>> x = int(raw_input("Please enter an integer: "))
Please enter an integer: 42
>>> type(x)
<type 'int'>
>>> if x < 0:
	x = 0
	print 'Negative change to zero'
elif  x == 0:
	print 'Zero'
elif  x == 1:
	print 'Single'
else:
	print 'More'

More
>>> 
>>> my_list = ['cat', 'window', 'defenestrate']
>>> for x in my_list:
	print x, len(x)

	
cat 3
window 6
defenestrate 12
>>> 
>>> for x in my_list[:]:
	if len(x) > 6:
		my_list.insert(0,x)

		
>>> my_list
['defenestrate', 'cat', 'window', 'defenestrate']