「Python if for」の版間の差分
ナビゲーションに移動
検索に移動
| 1行目: | 1行目: | ||
| − | == | + | ==[[Python]]i if for== |
[[Python]] | | [[Python]] | | ||
| − | + | [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 | + | 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
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']
© 2006 矢木浩人