PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in range(10):
... print i
...
0
1
2
3
4
5
6
7
8
9
>>> for i in range(4):
... for j in range(4):
... print i,j
...
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
3 0
3 1
3 2
3 3
>>> x=0
>>> for i in range(4):
... x+=i
... for j in range(4):
... x+=j
...
>>> x
30
>>>
>>> x=0
>>> for i in range(4):
... x-=i
... for j in range(4):
... x+=j
...
>>> x
18
>>> a=[1,2,3,4]
>>> a[2]=5
>>> a
[1, 2, 5, 4]
>>> a=(1,2,3,4)
>>> a[2]=5
Traceback (most recent call last):
File "", line 1, in ?
TypeError: object does not support item assignment
>>> {[1,2]:2,[2,3]:3}
Traceback (most recent call last):
File "", line 1, in ?
TypeError: list objects are unhashable
>>> {(1,2):2,(2,3):3}
{(1, 2): 2, (2, 3): 3}
>>>
>>> a=range(10)
>>> a=[i/10.0 for i in a]
>>> a
[0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, 0.80000000000000004, 0.90000000000000002]
>>> for i in a: print "%1.1f"%i
...
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
>>> a=0
>>> while a<1.0:
... print a
... a+=.1
...
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
>>> range(.1,1,.1)
C:\Python24\Scripts\pycrust:1: DeprecationWarning: integer argument expected, got float
#!/usr/bin/env python
Traceback (most recent call last):
File "", line 1, in ?
ValueError: range() step argument must not be zero
>>> a="x"
>>> while len(a)<60:
... a+=a
...
>>> a
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>> len(a)
64
>>> a="x"
>>> while len(a)<60:
... print a
... a+=a
...
x
xx
xxxx
xxxxxxxx
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> x
18
>>> a
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>> a="x"
>>> while len(a)<65:
... print a
... a+=a
...
x
xx
xxxx
xxxxxxxx
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> a
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>> for i in range(10):
... print i
... else: print "done"
...
File "", line 3
else: print "done"
^
SyntaxError: invalid syntax
>>> for i in range(10):
... print i
... else: print "done"
...
0
1
2
3
4
5
6
7
8
9
done
>>> for i in range(10):
... if i>7: break
... print i
... else: print "done"
...
0
1
2
3
4
5
6
7
>>> for i in range(10):
... if i>7: continue
... print i
... else: print "done"
...
0
1
2
3
4
5
6
7
done
>>> for i in range(10):
... if i>7: continue
... print i
... else: print "done"
...
0
1
2
3
4
5
6
7
done
>>> for i in range(10):
... print "a",i
... if i>7: continue
... print "b",i
... else: print "done"
...
a 0
b 0
a 1
b 1
a 2
b 2
a 3
b 3
a 4
b 4
a 5
b 5
a 6
b 6
a 7
b 7
a 8
a 9
done
>>> 7>7
False
>>> 7>=7
True
>>> 0.5
0.5
>>> .01
0.01
>>> .1
0.10000000000000001
>>> 1/2+1/4+1/8+1/16
0
>>> 1/2.0
0.5
>>> 1/4.0
0.25
>>> 1/2.0+1/4.0
0.75
>>> (.1+.1)>.2
False
>>> .2
0.20000000000000001
>>> a="test"
>>> if a=="hi": print "there"
... elif a=="there: print "mr"
File "", line 2
elif a=="there: print "mr"
^
SyntaxError: invalid syntax
>>> if a=="hi": print "there"
... elif a=="there": print "mr"
... else: print "nothing"
...
nothing
>>> a=4
>>> if a>5 : print "5"
... elif a>4 : print "4"
... elif a>3 : print "3"
... elif a>2 : print "2"
... elif a>1 : print "1"
...
3
>>> if a>5 : print "5"
...
>>> if a>4 : print "4"
...
>>> if a>3 : print "3"
...
3
>>> if a>2 : print "2"
...
2
>>> if a>5 : print "5"
... elif a>4 : print "4"
... elif a>3 : print "3"
... elif a>2 : print "2"
... elif a>1 : print "1"
... else: print "nothing"
...
3
>>> a=0
>>> if a>5 : print "5"
... elif a>4 : print "4"
... elif a>3 : print "3"
... elif a>2 : print "2"
... elif a>1 : print "1"
... else: print "nothing"
...
nothing
>>> a=5
>>> isinstance(a,int)
True
>>> isinstance(a,float)
False
>>> isinstance(a,str)
False
>>> a="abc"
>>> isinstance(a,int)
False
>>> isinstance(a,float)
False
>>> isinstance(a,str)
True
>>> a=[1,2,3]
>>> isinstance(a,list)
True
>>> str(a)
'[1, 2, 3]'
>>> a=3
>>> if a>2 : print "true"
...
true
>>> if not a>2 : print "true"
...
>>> if a<=2 : print "true"
...
>>> if a>2 and len(str(a))>1 : print "true"
...
>>> if a>2 or len(str(a))>1 : print "true"
...
true
>>>