Saturday, July 6, 2019

Reading and Writing files in python

""" ***********************************************
programming Language :Python
Tool(IDE) used :Anaconda -> Spider
started date:06-07-2019
latest modified date:06-07-2019
version:1.0
created by:ANIL DURGAM
*****************************************************"""
fred=open("hello","w")
fred.write("hello world")
fred.close()
read_file=open("hello","r")
file_read=read_file.read()
read_file.close()
print(file_read)

list and tuple function usage in python

""" ***********************************************
programming Language :Python
Tool(IDE) used :Anaconda -> Spider
started date:06-07-2019
latest modified date:06-07-2019
version:1.0
created by:ANIL DURGAM
*****************************************************"""
FoodTuple=("egg","bread","chicken")
print(FoodTuple)
FoodList=list(FoodTuple)
print(FoodList)
newfoodtuple=tuple(FoodList)
print(newfoodtuple)


output:
('egg', 'bread', 'chicken')
['egg', 'bread', 'chicken']
('egg', 'bread', 'chicken')

immutable type in python

firstTuple[0]="EGG"
print(firstTuple)

output::

NameError: name 'firstTuple' is not defined

example 2:

firstTuple="EGG"
print(firstTuple)

out put:
EGG


sub string in python


""" ***********************************************
programming Language :Python
Tool(IDE) used :Anaconda -> Spider
started date:06-07-2019
latest modified date:06-07-2019
version:1.0
created by:ANIL DURGAM

*****************************************************"""


word="pig"
pigLatinword=word[1:]+word[0]+"ay"
print(pigLatinword)
print(word[0])
print(word[1])
print(word[2])
word1="pygame"
print(word1[1:])
print(word1[2:])
print(word1[0:])

python class topic video