Friday, 22 November 2013
Monday, 23 September 2013
working with tuple and file
for i in range(0,100,5):
print i
# working with file in python
crip=open("flash.txt","w")
crip.write("sing the melody")
crip.close()
print crip
#reading a file
x=open("flash.text","r")
y=x.read()
x.close()
print y
#create a file
sunday=open("sunday.txt","w")
sunday.write("I enjoy the sermon of my bishop.\nI went at my frd house.\nlater in the evening i was enjoy myself with mara and clara show.")
sunday.close()
#reading a file
truth=open("sunday.txt","r")
trust=truth.read()
truth.close()
print trust
#appending a file
weekend=open("sunday.txt","a")
weekend.write("\nat twelve in the night,I went to bed.")
weekend.close()
#reading a file
capitol=open("sunday.txt","r")
mountain=capitol.read()
capitol.close()
print (mountain)
print i
# working with file in python
crip=open("flash.txt","w")
crip.write("sing the melody")
crip.close()
print crip
#reading a file
x=open("flash.text","r")
y=x.read()
x.close()
print y
#create a file
sunday=open("sunday.txt","w")
sunday.write("I enjoy the sermon of my bishop.\nI went at my frd house.\nlater in the evening i was enjoy myself with mara and clara show.")
sunday.close()
#reading a file
truth=open("sunday.txt","r")
trust=truth.read()
truth.close()
print trust
#appending a file
weekend=open("sunday.txt","a")
weekend.write("\nat twelve in the night,I went to bed.")
weekend.close()
#reading a file
capitol=open("sunday.txt","r")
mountain=capitol.read()
capitol.close()
print (mountain)
Friday, 20 September 2013
working loops and while range
for letter in 'python':
print 'current letter:',letter
#create a list called colors
colors=['pink','lermongreen','purpule','blue','yellow','orange']
for h in colors:
print h,'is your favorite color'
#using range function
for a in range(10):
print (a)
for x in xrange(30):
if x % 2==0:
continue
print x
for y in range(20):
if y %2!=0:
continue
print y
for x in xrange(500,599):
if x %2!=0:
continue
print x
#working with while loops
count=0
while (count < 9):
print 'the count is :' ,count
count= count +1
count=11
while (count < 11):
print 'the count is :' ,count
count= count +1
mars=11
while (mars <35):
print 'this number is not greater than:',mars
mars=mars+1
print 'current letter:',letter
#create a list called colors
colors=['pink','lermongreen','purpule','blue','yellow','orange']
for h in colors:
print h,'is your favorite color'
#using range function
for a in range(10):
print (a)
for x in xrange(30):
if x % 2==0:
continue
print x
for y in range(20):
if y %2!=0:
continue
print y
for x in xrange(500,599):
if x %2!=0:
continue
print x
#working with while loops
count=0
while (count < 9):
print 'the count is :' ,count
count= count +1
count=11
while (count < 11):
print 'the count is :' ,count
count= count +1
mars=11
while (mars <35):
print 'this number is not greater than:',mars
mars=mars+1
Wednesday, 18 September 2013
working with function in alist
continent=['Asia','europe','Africa']
print continent
#indexing a continent
earth=continent[2]
print earth
#modifying a list
continent[2]='Austratila'
print continent
# adding to a list
continent.append('america')
print continent
#deleting using pop
continent.pop(1)
print continent
#deleting using remove
del(continent[0])
print continent
girls=3
def calculate(x):
return x*4
print calculate(girls)
#create a list called Lib
lib=['buchanan','greenville','robertsport','kakata','zwedru','monrovia']
print lib
def home(new_list):
return new_list[2]
print home(lib)
#deleting function from the list
def moon(galaxy):
galaxy.pop(4)
return galaxy
print moon(lib)
#adding function to list
def earth(axis,new):
axis.append(new)
return axis
print earth(lib,'Gbarnga')
#joining two list
count=[1,2,3,4,5,6,7,8,9,10]
def join_list(word,number):
return word+number
print join_list(lib,count)
#using list for
for i in count:
print i+1
for k in lib:
print k
streets=[[1,2,3],[6,8,7,9]]
def shine(m):
result=sum(m,[])
return result
print shine(streets)
print continent
#indexing a continent
earth=continent[2]
print earth
#modifying a list
continent[2]='Austratila'
print continent
# adding to a list
continent.append('america')
print continent
#deleting using pop
continent.pop(1)
print continent
#deleting using remove
del(continent[0])
print continent
girls=3
def calculate(x):
return x*4
print calculate(girls)
#create a list called Lib
lib=['buchanan','greenville','robertsport','kakata','zwedru','monrovia']
print lib
def home(new_list):
return new_list[2]
print home(lib)
#deleting function from the list
def moon(galaxy):
galaxy.pop(4)
return galaxy
print moon(lib)
#adding function to list
def earth(axis,new):
axis.append(new)
return axis
print earth(lib,'Gbarnga')
#joining two list
count=[1,2,3,4,5,6,7,8,9,10]
def join_list(word,number):
return word+number
print join_list(lib,count)
#using list for
for i in count:
print i+1
for k in lib:
print k
streets=[[1,2,3],[6,8,7,9]]
def shine(m):
result=sum(m,[])
return result
print shine(streets)
Monday, 16 September 2013
working with list and dictionary
# eate a list called "content" which should contained all the contients and print
continent=['africa','antarctia','asia','austraclia','europe','northamerica','southamerica']
print continent
# print only the fifth(5)continent from the list
print continent[5]
# update the contient list by adding two plants earth and mars
continent.append('earth')
print continent
continent.append('mars')
print continent
#change the third contient on the list to pluto
continent[3]="pluto"
print continent
# print the number of items in the list
print len(continent)
#break the list into two
galaxy=continent[0:5]
print galaxy
space=continent[4:8]
print space
#adding "mercury" in the middle of the continent list and print
continent.insert(4,"mercury")
print continent
#by looping,print in the entire contients items
for items in continent:
print items
# create a list of thencountries in africa and print using loop
african_countries=['nigeria','ethiopia','egypt','congo','southafrica','tazania','kenya','algeria','unganda','sunda','morocco','ghana','mozanbique','ivorycoast',
'madagasca','angola','cameroom','niger','burkinafsco','mali','malawi','zambia','senegal','zimbawe','chad','guinea','gunisia','rwanda','benin',
'somila','burund','togo','liba','sierraleone','centralafricarepublic','emtrea','republicofcongo','liberia','mauritania','gabon','nimibia',
'botswana','lesotho','equatorialguinea','gambia','guineabossau','mauritius','swaziland','djbouti','reunionfrance','westernsahara','capeverde',
'mayotte(france)','saotomeandprincipe','seychelles','sainthelena']
for country in african_countries:
print country
# Delete the list called "space"
del(space)
print continent
# working with Dictionary
liberia={'bomic':'gola','bong':'kpelleh','gbarpolu':'dee','grandbassa':'bassa','grandcapemount':'vai','grandgeddeh':'krahn','grandkru':'kru','lofa':'lorma',
'margiba':'menda','monserrado':'english','nimba':'gio','rivercess':'bassa','rivergee':'kru','sinoe':'kru'}
print liberia
# print the ninth key in the dictionary
print liberia['margiba']
# the value fullah key to the key normans
liberia['normans']='fullah'
print liberia
#create an empty dictionary call street and assigned numbers to them as values print the dictionary
street={}
street['center']=20
street['broad']=23
street['clay']=40
street['front']=26
street['benson']=50
print street
# delete anyone of the items from the dictionary liberia
del (street['clay'])
print street
#add a key drapline to the street dictionary and add 8,3,11,2 as values and print
street['drapline']=[8,3,9,11,2]
print street
#sort the list that was added to drapline in the street
street['drapline'].sort()
print street
#creat your own dictionary of five words
vocationalschool_college={'cheale':'behind lonestar','ilab':'behind jfk','umu':'ashumstreet','lu':'capitol','stmary':'dula'}
print vocationalschool_college
continent=['africa','antarctia','asia','austraclia','europe','northamerica','southamerica']
print continent
# print only the fifth(5)continent from the list
print continent[5]
# update the contient list by adding two plants earth and mars
continent.append('earth')
print continent
continent.append('mars')
print continent
#change the third contient on the list to pluto
continent[3]="pluto"
print continent
# print the number of items in the list
print len(continent)
#break the list into two
galaxy=continent[0:5]
print galaxy
space=continent[4:8]
print space
#adding "mercury" in the middle of the continent list and print
continent.insert(4,"mercury")
print continent
#by looping,print in the entire contients items
for items in continent:
print items
# create a list of thencountries in africa and print using loop
african_countries=['nigeria','ethiopia','egypt','congo','southafrica','tazania','kenya','algeria','unganda','sunda','morocco','ghana','mozanbique','ivorycoast',
'madagasca','angola','cameroom','niger','burkinafsco','mali','malawi','zambia','senegal','zimbawe','chad','guinea','gunisia','rwanda','benin',
'somila','burund','togo','liba','sierraleone','centralafricarepublic','emtrea','republicofcongo','liberia','mauritania','gabon','nimibia',
'botswana','lesotho','equatorialguinea','gambia','guineabossau','mauritius','swaziland','djbouti','reunionfrance','westernsahara','capeverde',
'mayotte(france)','saotomeandprincipe','seychelles','sainthelena']
for country in african_countries:
print country
# Delete the list called "space"
del(space)
print continent
# working with Dictionary
liberia={'bomic':'gola','bong':'kpelleh','gbarpolu':'dee','grandbassa':'bassa','grandcapemount':'vai','grandgeddeh':'krahn','grandkru':'kru','lofa':'lorma',
'margiba':'menda','monserrado':'english','nimba':'gio','rivercess':'bassa','rivergee':'kru','sinoe':'kru'}
print liberia
# print the ninth key in the dictionary
print liberia['margiba']
# the value fullah key to the key normans
liberia['normans']='fullah'
print liberia
#create an empty dictionary call street and assigned numbers to them as values print the dictionary
street={}
street['center']=20
street['broad']=23
street['clay']=40
street['front']=26
street['benson']=50
print street
# delete anyone of the items from the dictionary liberia
del (street['clay'])
print street
#add a key drapline to the street dictionary and add 8,3,11,2 as values and print
street['drapline']=[8,3,9,11,2]
print street
#sort the list that was added to drapline in the street
street['drapline'].sort()
print street
#creat your own dictionary of five words
vocationalschool_college={'cheale':'behind lonestar','ilab':'behind jfk','umu':'ashumstreet','lu':'capitol','stmary':'dula'}
print vocationalschool_college
Monday, 9 September 2013
why we were created frds?
if you don't know,we were created for God Pleasure.
if you discover who you are then you will discover who God is?
you can go to the next chapter if you fear God.
what will separate me from the love God?
ans:nothing will separate me from the love of God buz I luv him so much.
if you don't know,we were created for God Pleasure.
if you discover who you are then you will discover who God is?
you can go to the next chapter if you fear God.
what will separate me from the love God?
ans:nothing will separate me from the love of God buz I luv him so much.
Friday, 6 September 2013
working with Dictionary
school={'teacher':7,'students':20,'Janitor':1,'cook':3,'principal':1, 'cashier':2}
print school
# up dating a dictionary
school['sponser']=6
print school
# prints key in the & value in the dict
print school.keys()
# print value in the dict
print school.values()
# print value of a key
print school['students']
# deleting an item from dict
del(school['Janitor'])
print school
# count the # of the dict
print len(school)
# five menu to the list
menu={}
menu['cornbread']=150
menu['coatsoup']=450
menu['vegetablesalade']=650
menu['dryrice']=100
menu['vento']=180
menu['orangefanta']=40
menu['malta']=190
menu['fufusoup']=250
menu['extrajuice']=290
print menu
for key,value in menu.items():
print key,value
# adding list to a dictionary
citizens={'Liberia':'Liberians','Nigeria':'Nigerins','Americans':['chinese','europeans','Africans','Asians']}
print citizens
# using for loop
for key,value in citizens.items():
print key,value
citizens['Americans'].sort()
print citizens
# update citizens
citizens['brazil']=['brazilians','southAmericans']
print citizens
print school
# up dating a dictionary
school['sponser']=6
print school
# prints key in the & value in the dict
print school.keys()
# print value in the dict
print school.values()
# print value of a key
print school['students']
# deleting an item from dict
del(school['Janitor'])
print school
# count the # of the dict
print len(school)
# five menu to the list
menu={}
menu['cornbread']=150
menu['coatsoup']=450
menu['vegetablesalade']=650
menu['dryrice']=100
menu['vento']=180
menu['orangefanta']=40
menu['malta']=190
menu['fufusoup']=250
menu['extrajuice']=290
print menu
for key,value in menu.items():
print key,value
# adding list to a dictionary
citizens={'Liberia':'Liberians','Nigeria':'Nigerins','Americans':['chinese','europeans','Africans','Asians']}
print citizens
# using for loop
for key,value in citizens.items():
print key,value
citizens['Americans'].sort()
print citizens
# update citizens
citizens['brazil']=['brazilians','southAmericans']
print citizens
Subscribe to:
Posts (Atom)