numb = input("Enter a number: ") #get the number
print 'numb<10 is',int(numb < 10)
print 'numb>10 is',int(numb > 10)
print 'numb==10 is',int(numb == 10),'\n'
for j in range(15): #for loop from 0 to 14
print j*j,'', #displaying the square of j
numb = 1 #define noop variable
for numb in range(1,11): #loop from 1 to 10
print '%4d' %(numb), #display first column
cube = numb*numb*numb #calculate cube
print '%6d' %(cube) #display 2nd column
fact = 1
numb = input("Enter a number: ") #get number
for j in range(numb,1,-1): #loop from numb to 1 (numb , numb-1 , .... , 2 , 1)
fact *= j #multiply by j
print 'Factorial is',fact,'\n' #display the factorial of the number
n = 99
while(n!=0): #loop untill n is 0
n = input() #read a number into n
print #for end line
pow = 1 #power variable initially 1
numb = 1 #numb goes from 1 to ???
while(pow<10000): #loop untill power <= 4 digits
print '%2d' %(numb), #display number
print '%5d' %(pow) #display 4th power
numb += 1 #get for next power
pow = numb*numb*numb*numb #calculate forth power
limit = 4294967295 #largest unsigned long
next = 0 #next-to-last term
last = 1 #last term
while(next<limit/2): #don't let results get too big
print last,'', #display last term
sum = next + last #add last two terms
next = last #variables move forword in the series
last = sum
print '\n'
while True: #start while loop
#find out the quotient and remainder
dividend = input("Enter dividend: ")
divisor = input("Enter divisor: ")
print 'Quotient is',dividend / divisor,
print ', Remainder is',dividend % divisor
ch = raw_input("Do another? (y/n): ") #do it again
if(ch == 'n'): #loop condition
break;
x = input("Enter a number: ") #get input
if(x > 100): #check whether a number is greater than 100 or not
print 'That number is greater than 100 \n'
x = input("Enter a number: ") #get input
if(x > 100): #check whether a number is greater than 100 or not
print 'That number',x, #print the number
print 'is greater than 100 \n'
n = input("Enter a number: ") #get input to test
b=0
for j in range(2,n/2+1,1): #divide by every integer from 2
if(n%j == 0): #if remainder is 0
print 'It\'s not prime; divisible by',j #it's divisible by j
b=1
break
if b==0:
print 'It\'s prime'
x = input("Enter a number: ") #get input
if x>100: #if input is greater than 100
print 'That number is greater than 100\n'
else: #if input less than or equal to 100
print 'That number is not greater than 100\n'
chcount = 0 #counts non-space characters
wdcount = 1 #counts spaces between words
ch = 'a'
ch = raw_input("Enter a phrase: ") #geting the line
for j in range(len(ch)): #for loop till line ends
if ch[j] == ' ': #if it's a space
wdcount += 1 #count a word
else: #otherwise
chcount += 1 #count a character
print 'Words =',wdcount,'\nLetters =',(chcount),'\n' #display result
chcount = 0 #counts non-space characters
wdcount = 1 #counts spaces between words
ch = 'a'
ch = raw_input("Enter a phrase: ") #geting the line
for j in range(len(ch)): #for loop till line ends
if ch[j] == ' ': #if it's a space
wdcount += 1 #count a word
else: #otherwise
chcount += 1 #count a character
print 'Words =',wdcount,'\nLetters =',(chcount),'\n' #display result
dir = 'a'
x = 10
y = 10
print 'Type Enter to quit'
while(dir != '\n'): #untill Enter is typed
print 'Your location is',x,',',y
dir = raw_input('\nPress direction key (n, s, e, w): ') #get direction
if dir == 'n': #go north
y += 1
else:
if dir == 's': #go south
y -= 1
else:
if dir == 'e': #go east
x += 1
else:
if dir == 'w': #go west
x-=1
else:
break
#get three numbers
print 'Enter three number, a, b, c:'
a = input()
b = input()
c = input()
if a==b: #if a=b
if b==c: #if b=c i.e. all three numbers are same
print 'a, b, and c are the same\n'
else:
print 'b and c are different\n'
else: #if a != b
print 'a and b are different\n'
dir = 'a'
x = 10
y = 10
print 'Type Enter to quit'
while(dir != '\n'): #untill Enter is typed
print 'Your location is',x,',',y
dir = raw_input('\nPress direction key (n, s, e, w): ') #get charcter
if dir == 'n': #go north
y += 1
elif dir == 's': #go south
y -= 1
elif dir == 'e': #go east
x += 1
elif dir == 'w': #go west
x -= 1
else:
break
speed = input("Enter 33, 45, or 78: ") #get value of speed from user
#selection based on speed
if speed == 33: #if user entered 33
print 'LP album\n'
elif speed == 45: #if user entered 45
print 'Single selection\n'
elif speed == 78: #if user entered 78
print 'Obsolete formate\n'
dir = 'a'
x = 10
y = 10
print 'Type Enter to quit'
while(dir != '\n'): #untill Enter is typed
print 'Your location is',x,',',y
dir = raw_input('\nPress direction key (n, s, e, w): ') #get charcter
if dir == 'n': #go north
y += 1
elif dir == 's': #go south
y -= 1
elif dir == 'e': #go east
x += 1
elif dir == 'w': #go west
x -= 1
elif not dir:
print 'Exiting'
break
else:
print 'Try again'
for j in range(80): #for every column
ch = '' if j%8 else 'X' #ch is 'x' if column is multiple of 8 and ' ' (space) otherwise
print ch,
dir = 'a'
x = 10
y = 10
print 'Type Enter to quit'
while(dir != '\n'): #untill Enter is typed
print 'Your location is',x,',',y
dir = raw_input('\nPress direction key (n, s, e, w): ') #get charcter
#Update coordinates
if dir == 'n': #go north
y -= 1
elif dir == 's': #go south
y += 1
elif dir == 'e': #go east
x += 1
elif dir == 'w': #go west
x -= 1
else:
break
if x == 7 and y == 11: #if x is 7 and y is 11
print 'You found the treasure'
break; #exit from program
dir = 'a'
x = 10
y = 10
print 'Type Enter to quit'
while(dir != '\n'): #untill Enter is typed
print 'Your location is',x,',',y
if x < 5 or x > 15: #if x west of 5 and x east 15
print 'Beware: dragons lurk here'
dir = raw_input('\nPress direction key (n, s, e, w): ') #get charcter
#Update coordinates
if dir == 'n': #go north
y -= 1
elif dir == 's': #go south
y += 1
elif dir == 'e': #go east
x += 1
elif dir == 'w': #go west
x -= 1
else:
break
while True:
dividend = input("\nEnter dividend: ")
divisor = input("Enetre divisor")
if divisor==0: #if attempt to divide by 0
print 'Illegal divisor' #display message
continue #go to top of loop
print 'Quotient is',dividend/divisor
print 'remainder is',dividend%divisor
ch = raw_input('Do another? (y/n): ')
if(ch=='n'):
break