Archive for the ‘Python’ Category

Chapter 4 – Python String Operations Part 1

 
Step 1
 
Open any text editor (gedit,pico,vi,nano) then enter the following python script and save the file with .py extension.
 
#!/usr/bin/python
#Author : Jijo K Jose
 
print "\n————————————\nChapter 4 – String 1\n————————————\n"
 
a = raw_input("Enter any string : ")
print "%s contains %d character" %(a,len(a))
print "\nLast character of %s is : %s" %(a,a[len(a)-1])
print "\nFirst 3 characters are : %s" %(a[0:3])
print "\nEach Characters are…"
for ch in a:
print ch
b = raw_input("\nEnter second string : ")
if a==b:
print "\nStrings are equal"
else:
print "\nStrings are not equal"
 
print "\n————————————\n"
 
#END
 

Read more »

Chapter 3 – Python Keyboard Inputs

 
Step 1
 
Open any text editor (gedit,pico,vi,nano) then enter the following python script and save the file with .py extension.
 
#!/usr/bin/python
#Author : Jijo K Jose
 
 
print "\n————————————\nChapter 3 – STDIN Input\n————————————\n"
 
msg = raw_input("Enter Your Name : ")
age = input("Enter your age : ")
print "Your name is :" , msg
print "%s, your age is : %d" %(msg,age)
 
print "\n————————————\n"
 
#END

 

Read more »

Chapter 2 – Python Math Functions

 
Step 1
 
Open any text editor (gedit,pico,vi,nano) then enter the following python script and save the file with .py extension.
 
#!/usr/bin/python
#Author : Jijo K Jose
 
print "\n————————————\nChapter 2 – Math Function\n————————————\n"
 
print "100 divided by 16 is:", 100 / 16 , "& Remainder is:", 100 % 16
 
#END
 

Read more »