Professional Documents
Culture Documents
Adobe Scan 10 Dec 2023
Adobe Scan 10 Dec 2023
9)
Format Run Options Window Help
count INDIA () :
f= open ( "my file. txt" , 'r' )
count= 0
fo,;_ line in f:
for word in line.split():
if (word== "India" ) or (word== "india" }:
count= count +1
else :
continue
print (count)
count INDIA ()
I
X +
file ~It
Hi this is india. india is diverse. india has many festivals. india is good . india has a very big population . people of india are very
nice. food of india is delicious. India is nice .I
\D es kt .o p
Im~"!::'kiop data/Documents/Python/count vowel.py (3.7.9)
print (count)
countVowel ()
X +
f line f :
f (line.startswith(' An' )) or (line. startswith(' an ')) cL (line . s tart s with(' a ')) r (line . startswi th (' A ' J J 01 (line. startswi th (•the')) o - (line. startswith (•The•)) :
p r i nt (line)
COONTLINES ()
IIIIIJJS aJ,nents/Pvtho
Run Options Wtndow Help
) :
'EST FILE. txt", 'r' )
. f:
~ _ a r t - ca.1i t-h i '.A.IL~\ L ----cu:'----- i 1 :i nP c::t ;:i rt" c::w-i r h ( 'r1n ' , \ n:r- l 1 i nP c::r rt rt- c.ui t" h I ';:1.' \..
I TESTFILE X +
File Edit View
~
'· · indow HeJ I
1I I
In world.
>>> I
esktop·data/Documents/Python/count And.py (3].9)*
,te Edit Format Run Options Wigdo)N Help
def . COUNT_AND {}:
f= open {''5',I'ORY. txt" , ' r ·' )
count= 0
for line in f:
for word in line.split():
if" (word== ' AND ' ) or (word== 'and' ) or (word== 'And ' }:
,..count+=l
print ,( word)
prin t
• I
(count}
toUNT _AND ()
File Edit View
sneha and raj are goi ng somewhere. they are tired And hungry. with them are sonal AND Rahul. all are worki ng ANd st
school· and college respectively . AnD bored. I
17 2020, 1
""' ., '·
n·, · ·ncredits 11 YJt* 11 -li:~se ()" fo
'.Le~
· . ART: D: /Desktop data/Docume nts/Pytho
-1!1!1!1~'1".IIJesltlDo" data/DOcuments?Pyttion/word with tor T.py (3.7.9)
Edit Format Run Options Window Help
DISPLAYWORDS O :-
f= open (rrSTORY.txt" , 'r' )
count= 0
for line in f;
for word in line.split(): I
if (word.startswith( "T" )) or (word.startswith( "t" )):
count= count+ 1
print (word)
print(count)
ISPLAYWORDS ()
111' ryu JUI I J. I •J JJ"ICJ
Iii
FiJe Edit Shen Debug Options Window Help
Python 3.7.9 (tags/v3.7.9:13c947 47c7, Aug 17 2020
(AMD64)J on win32
Type "help", "copyr-igh:t:", "credits" or "license ( J
>>>
RESTART: D:/Desktop data/Documents/Pyt h
they
tired
em
ey
>> I
==
_,1,,u,••··•V.PY - 0-./0esktop data/Documents/Python/starting with P.py (3.7.9)
Run Options Window
- B () : '
T
X +
:Etfn View
, U' ~- . = -~ -;,,,"'._
· }·~r.ots~v=i-s1t my school.
par.r ots are small.
.tions
. ... : ''····•-•·;,.;,m,, __ ,
7 .. 9:1 >
:/Desktop
my school.
>>> I
., y- . es op data/Documents/Python/cound ending
oOptiocis Window --
,() ; /
f- • - -· ·TEST FILE~ txt u , 1 r 1 )
count;:;;0;;,a
' -
for ,l. \ -- :.n : f:
.in line,. split (} :
; 1·1
, ; ... "Hf.
I~ 1- ljf,
lh
count words~~ ()
File , &.Ht Vi,ew
II
world is nice.
Good work
,II
II I Iii
11/11111 1111/1 'I I I
a... 3 1.9 Shell
File Edrt Shell Debug Opbons Window He p
Python 3.7. 9 (tags 3.7.9:13c94747c7, Aug 1
(AMD64)] on win32
Type "help", "copyright", "credits " or "license (
>>>
--==
source
RESTART: D:/Desktop data/Documents/Pytho
The
little
3
>>> I
. lji I ' I " "]f/1.:1f:"
eJlt r
.,
\ r
• fi;:11 I I
reverseFile ()
I
Cn-s_ ow Help
- -
f- :: •
i ht elttil ehT ·
3-