For Loop
names = ['John', 'Jerome', 'Paul']
for m in range(len(names)):
print(names[m]);
m=m+1;
While Loop
names = ['John', 'Jerome', 'Paul', 'George', 'Andy', 'Michael']
i = 0
while i < len(names):
print(names[i])
i += 1
Get Information about Interface
names = ['John', 'Jerome', 'Paul']
for m in range(len(names)):
print(names[m]);
m=m+1;
While Loop
names = ['John', 'Jerome', 'Paul', 'George', 'Andy', 'Michael']
i = 0
while i < len(names):
print(names[i])
i += 1
Get Information about Interface
import collections
print(collections.__doc__);
Variable Number of Arguments
def manyArgs(*arg):
print("I was called with", len(arg), "arguments:", arg)
manyArgs(1,2,3)
def manyArgs(*args):
result=0;
for arg in args:
result+=arg;
return result;
print(manyArgs(1,2,3)) # Hello World program in Python
import datetime,time
def welcome():
print("Hi How are you" +str(datetime.datetime.now()));
print("Hope you are having a great day");
print("Welcome to python");
time.sleep(1);
welcome();
welcome(); Checking value in a array # Hello World program in Python
names=['Anil','Ram','Rakesh','Shan'];
if 'Anil' in names:
print("True");
else:
print("Flase");
Regex example of Python #regular expression example
import re
orRegex=re.compile(r'c(ricketer|lass|ollege)');
mo=orRegex.search('My name is Rahul dravid, I am cricketer i love Movie');
print(mo.group())
result=0;
for arg in args:
result+=arg;
return result;
print(manyArgs(1,2,3)) # Hello World program in Python
import datetime,time
def welcome():
print("Hi How are you" +str(datetime.datetime.now()));
print("Hope you are having a great day");
print("Welcome to python");
time.sleep(1);
welcome();
welcome(); Checking value in a array # Hello World program in Python
names=['Anil','Ram','Rakesh','Shan'];
if 'Anil' in names:
print("True");
else:
print("Flase");
Regex example of Python #regular expression example
import re
orRegex=re.compile(r'c(ricketer|lass|ollege)');
mo=orRegex.search('My name is Rahul dravid, I am cricketer i love Movie');
print(mo.group())
Comments
Post a Comment