print "Hello World"
Hello World
2+2
4
3-2
1
2**3
8
8%5
3
2.1+2
4.1
2.5 == 2.5
True
print 4.1
4.1
5/2
2
from __future__ import division
5/2
2.5
9.0/5
1.8
(1+2j)
(1+2j)
(1+2j)-(3+4j)
(-2-2j)
t=1.0, accel = 9.8
File "<ipython-input-13-97e205ccfbda>", line 1 t=1.0, accel = 9.8 SyntaxError: can't assign to literal
t, accel = 1.0, 9.8
'0b1110'
'0b1110'
0b1110
14
0b1110 << 1
28
0b1110 & 0b100
4
0b1110 & 0b1000
8
0b1110 ^ 0b100
10
5 < (2+4j)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-21-4a81da7d6116> in <module>() ----> 1 5 < (2+4j) TypeError: no ordering relation is defined for complex numbers
faren = raw_input("enter a value: ")
print faren
enter a value: 25 25
%%file number_game.py
x = 0
max_tries=10
count = 0
while True:
x_new = int(raw_input("Enter a new number: "))
if x_new > x:
print " => it's bigger than the last!"
elif x_new < x:
print " => it's smaller than the last!"
else:
print " => no changes! I'll exit now"
break
x = x_new
count += 1
if count > max_tries:
print "too many tries..."
break
Writing number_game.py
%run number_game.py
Enter a new number: 5 => it's bigger than the last! Enter a new number: 8 => it's bigger than the last! Enter a new number: 5 => it's smaller than the last! Enter a new number: 5 => no changes! I'll exit now
%%file breakout01.py
final_str=""
input_str=""
Done = False
while not(Done) :
input_str=raw_input("Enter a word (. | or ? to end): ")
final_str+=(input_str+" ")
if input_str in ('.','!','?'):
Done = True
break
print final_str
Overwriting breakout01.py
%run breakout01.py
Enter a word (. | or ? to end): Hi Enter a word (. | or ? to end): This Enter a word (. | or ? to end): Is Enter a word (. | or ? to end): Gautam Enter a word (. | or ? to end): ? Hi This Is Gautam ?