Simple python example

#!/usr/bin/python

import os

def printMenu():
    print "Hello World"

def getChoice():
    return raw_input("Enter your choice:")

printMenu()
y = getChoice()
print "Your choice:", y
print range(20)
word = "this is a long sentence"
print len(word)
print word[:]
print word[0]
# while loop 
i = 0
while (i < len(word)):
   print word[i]
   i += 1
   
# read a number   
i = int(raw_input("Enter number:"))
if (i<5):
	print "Less"
else:
	print "More"
	
   

pythonbasic.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0