SlideShare a Scribd company logo
READING WORDS FROM A STRING
COMPUTER SCIENCE
In t his w e d isc uss a bo ut t he reading
wordsfrom a string.
to read word by word from a string
WORDS from the STRINGLet Us First read
Initialize string in a variable nmSTEP 1:
nm=“This Statement wORK FOR READing WORDS from the String in a variable”
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
Use split to break the words and store it
inside another variable and the length.
STEP 2:
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
k store the number of words in a variable word. It is 12
0 1 2 3 4 5 6 7 8 9 10 11
Now start the loop first case for read the words
using and for..range/while x start from 0 to k-1
STEP 3:
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
Next is display the wordsSTEP 4:
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
Move to next word in loopSTEP 5:
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
x=x+1Increment
automatically
Increment
automatically
This line use for
Incrementing value
So Now You know how to split() and read
words from a string.
Let Us
Solve some of the examples using same format
that we discuss to read words
Q1. Program to count number of words whose length is more than 5 or display those words
whose length is more than 5
Q1. Program to count number of words whose length is more than 5 or display those
words whose length is more than 5
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k):
x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
x=x+1
Q1. Program to count number of words whose length is more than 5
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
x=x+1
First declare variable count=0 to count number of words whose length is more than 5
Q1. Program to count number of words whose length is more than 5
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
x=x+1
First declare variable count=0 to count number of words whose length is more than 5
Q1. Program to count number of words whose length is more than 5
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
print(word,end=“”)
print(word[x],end=“”)
print(word[x],end=“”)
x=x+1
First declare variable count=0 to count number of words whose length is more than 5
count=0
count=0 count=0
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
Next after for loop place if condition and check the length of the words are more
than 5 or not
count=0
count=0 count=0
if len(word[x]) > 5:
if len(word[x]) > 5:
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
After the if condition placed now put count inside if condition for countingcount
count=0
count=0 count=0
if len(word[x]) > 5:
if len(word[x]) > 5:
count=count+1
count=count+1
count=count+1
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
At last when all the words read and the check by if using len() and counting do no
we need to display how many words length more than 5
count=0
count=0 count=0
if len(word[x]) > 5:
if len(word[x]) > 5:
count=count+1
count=count+1
count=count+1print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
count=0
count=0 count=0
if len(word[x]) > 5:
if len(word[x]) > 5:
count=count+1
count=count+1
count=count+1print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
Q1. Program to display of words whose length is more than 5
First in this program remove the line of count=0 and count=count+1
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
if len(word[x]) > 5:
if len(word[x]) > 5:
print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
print(“No of words more than 5:”,count)
Q1. Program to display of words whose length is more than 5
Now inside the if condition write the print line only and remove the last print
word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
for word in nm.split(): word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if len(word) > 5:
x=x+1
if len(word[x]) > 5:
if len(word[x]) > 5:
print(word)
Q1. Program to display of words whose length is more than 5
Now inside the if condition write the print line only and remove the last print
function also, there is no need of print count.
print(word[x])
print(word[x])
Let Us
discuss some of the examples using same format
that we discuss to read words
Q1. Program to count number of “that” in a string.
Q2. Program to count number of words whose first character is VOWEL.
Q3. Program to count number of words whose first character is UPPERCASE
Q4. Program to count number of words whose first character is LOWERCASE
Q5. Program to copy words whose first character is VOWEL in a another variable.
word=[‘This’,’Statement’,’that’,’FOR’,’READing’,’WORDS’,’that’,’the’,’String’,’that’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement that…..” nm=“This Statement that…..” nm=“This Statement that…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if word in “that”:
x=x+1
if word[x] in “that”:
if word[x] in “that”:
Inside If condition just check using == “that” to check that word exists
Q1. Program to count number of “that” in a string.
count=0
count=0 count=0
count=count+1
print(“No of that::”,count)
count=count+1
print(“No of that::”,count)
count=count+1
print(“No of that::”,count)
word=[‘This’,’Statement’,’that’,’FOR’,’READing’,’WORDS’,’that’,’the’,’String’,’that’,’a’,’variable’]
for….in for….range while ..loop
nm=“This Statement that…..” nm=“This Statement that…..” nm=“This Statement that…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if word “that”:
x=x+1
if word[x] “that”:
if word[x] “that”:
Q1. Program to count number of “that” in a string.
count=0
count=0 count=0
count=count+1
print(“No of that::”,count)
count=count+1
print(“No of that::”,count)
count=count+1
print(“No of that::”,count)
==
==
==
word=[‘This’,’Items’,’that’,’or’,’READing’,’Advance’,’that’,’the’,’String’,’that’,’a’,’variable’]
for….in for….range while ..loop
nm=“This items that…..” nm=“This items that…..” nm=“This items that…..”
for word in nm.split():
word=nm.split()
k=len(word)
word=nm.split()
k=len(word)
for x in range(0,k): x=0
while x<k:
if word[0] in “AEIOUaeiou”:
x=x+1
if word[x][0] in “AEIOUaeiou”:
count=0
count=0 count=0
count=count+1
print(“No of vowel:”,count)
count=count+1
print(“No of vowel:”,count)
count=count+1
print(“No of vowel:”,count)
Q2. Program to count number of words whose first character is VOWEL.
if word[x][0] in “AEIOUaeiou”:

More Related Content

What's hot

Tree Leetcode - Interview Questions - Easy Collections
Tree Leetcode - Interview Questions - Easy CollectionsTree Leetcode - Interview Questions - Easy Collections
Tree Leetcode - Interview Questions - Easy Collections
Sunil Yadav
 
21 properties of division and roots x
21 properties of division and roots x21 properties of division and roots x
21 properties of division and roots x
math260
 
27 power series x
27 power series x27 power series x
27 power series x
math266
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: Deanonymizing
David Evans
 
22 double integrals
22 double integrals22 double integrals
22 double integralsmath267
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
String variable in php
String variable in phpString variable in php
String variable in phpchantholnet
 

What's hot (8)

Tree Leetcode - Interview Questions - Easy Collections
Tree Leetcode - Interview Questions - Easy CollectionsTree Leetcode - Interview Questions - Easy Collections
Tree Leetcode - Interview Questions - Easy Collections
 
21 properties of division and roots x
21 properties of division and roots x21 properties of division and roots x
21 properties of division and roots x
 
27 power series x
27 power series x27 power series x
27 power series x
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: Deanonymizing
 
22 double integrals
22 double integrals22 double integrals
22 double integrals
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
String variable in php
String variable in phpString variable in php
String variable in php
 

Similar to PYTHON-READ WORDS FROM STRING

Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) Services
Eelco Visser
 
Word chains
Word chainsWord chains
Word chains
Bob Marcus
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
Pedro Rodrigues
 
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
DoKC
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
Software Guru
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technologyppparthpatel123
 
Iteration
IterationIteration
Iteration
Pooja B S
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Philip Schwarz
 
A guide for teachers – Years 11 and 121 23
A guide for teachers – Years 11 and 121  23 A guide for teachers – Years 11 and 121  23
A guide for teachers – Years 11 and 121 23
mecklenburgstrelitzh
 
A guide for teachers – Years 11 and 121 23 .docx
A guide for teachers – Years 11 and 121  23 .docxA guide for teachers – Years 11 and 121  23 .docx
A guide for teachers – Years 11 and 121 23 .docx
makdul
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
faithxdunce63732
 
java_lect_03-2.ppt
java_lect_03-2.pptjava_lect_03-2.ppt
java_lect_03-2.ppt
kavitamittal18
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
carliotwaycave
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
Simon Proctor
 
Arithmetic sequences and series[1]
Arithmetic sequences and series[1]Arithmetic sequences and series[1]
Arithmetic sequences and series[1]indu psthakur
 
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
HPCC Systems
 
Perl intro
Perl introPerl intro
Perl intro
Swapnesh Singh
 

Similar to PYTHON-READ WORDS FROM STRING (18)

Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) Services
 
Word chains
Word chainsWord chains
Word chains
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
Dok Talks #115 - What More Can I Learn From My OpenTelemetry Traces?
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
 
Iteration
IterationIteration
Iteration
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
 
A guide for teachers – Years 11 and 121 23
A guide for teachers – Years 11 and 121  23 A guide for teachers – Years 11 and 121  23
A guide for teachers – Years 11 and 121 23
 
A guide for teachers – Years 11 and 121 23 .docx
A guide for teachers – Years 11 and 121  23 .docxA guide for teachers – Years 11 and 121  23 .docx
A guide for teachers – Years 11 and 121 23 .docx
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
 
java_lect_03-2.ppt
java_lect_03-2.pptjava_lect_03-2.ppt
java_lect_03-2.ppt
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
 
Arithmetic sequences and series[1]
Arithmetic sequences and series[1]Arithmetic sequences and series[1]
Arithmetic sequences and series[1]
 
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
Using High Dimensional Representation of Words (CBOW) to Find Domain Based Co...
 
Perl intro
Perl introPerl intro
Perl intro
 

More from vikram mahendra

Communication skill
Communication skillCommunication skill
Communication skill
vikram mahendra
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
vikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
vikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
vikram mahendra
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
vikram mahendra
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
vikram mahendra
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
vikram mahendra
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
vikram mahendra
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
vikram mahendra
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
vikram mahendra
 

More from vikram mahendra (20)

Communication skill
Communication skillCommunication skill
Communication skill
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 

Recently uploaded

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 

Recently uploaded (20)

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 

PYTHON-READ WORDS FROM STRING

  • 1. READING WORDS FROM A STRING COMPUTER SCIENCE
  • 2. In t his w e d isc uss a bo ut t he reading wordsfrom a string. to read word by word from a string WORDS from the STRINGLet Us First read
  • 3. Initialize string in a variable nmSTEP 1: nm=“This Statement wORK FOR READing WORDS from the String in a variable” for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..”
  • 4. Use split to break the words and store it inside another variable and the length. STEP 2: word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) k store the number of words in a variable word. It is 12 0 1 2 3 4 5 6 7 8 9 10 11
  • 5. Now start the loop first case for read the words using and for..range/while x start from 0 to k-1 STEP 3: word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k:
  • 6. Next is display the wordsSTEP 4: word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”)
  • 7. Move to next word in loopSTEP 5: word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”) x=x+1Increment automatically Increment automatically This line use for Incrementing value
  • 8. So Now You know how to split() and read words from a string. Let Us Solve some of the examples using same format that we discuss to read words Q1. Program to count number of words whose length is more than 5 or display those words whose length is more than 5
  • 9. Q1. Program to count number of words whose length is more than 5 or display those words whose length is more than 5 word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”) x=x+1
  • 10. Q1. Program to count number of words whose length is more than 5 word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”) x=x+1 First declare variable count=0 to count number of words whose length is more than 5
  • 11. Q1. Program to count number of words whose length is more than 5 word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”) x=x+1 First declare variable count=0 to count number of words whose length is more than 5
  • 12. Q1. Program to count number of words whose length is more than 5 word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: print(word,end=“”) print(word[x],end=“”) print(word[x],end=“”) x=x+1 First declare variable count=0 to count number of words whose length is more than 5 count=0 count=0 count=0
  • 13. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 Next after for loop place if condition and check the length of the words are more than 5 or not count=0 count=0 count=0 if len(word[x]) > 5: if len(word[x]) > 5:
  • 14. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 After the if condition placed now put count inside if condition for countingcount count=0 count=0 count=0 if len(word[x]) > 5: if len(word[x]) > 5: count=count+1 count=count+1 count=count+1
  • 15. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 At last when all the words read and the check by if using len() and counting do no we need to display how many words length more than 5 count=0 count=0 count=0 if len(word[x]) > 5: if len(word[x]) > 5: count=count+1 count=count+1 count=count+1print(“No of words more than 5:”,count) print(“No of words more than 5:”,count) print(“No of words more than 5:”,count)
  • 16. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 count=0 count=0 count=0 if len(word[x]) > 5: if len(word[x]) > 5: count=count+1 count=count+1 count=count+1print(“No of words more than 5:”,count) print(“No of words more than 5:”,count) print(“No of words more than 5:”,count) Q1. Program to display of words whose length is more than 5 First in this program remove the line of count=0 and count=count+1
  • 17. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 if len(word[x]) > 5: if len(word[x]) > 5: print(“No of words more than 5:”,count) print(“No of words more than 5:”,count) print(“No of words more than 5:”,count) Q1. Program to display of words whose length is more than 5 Now inside the if condition write the print line only and remove the last print
  • 18. word=[‘This’,’Statement’,’wORK’,’FOR’,’READing’,’WORDS’,’from’,’the’,’String’,’in’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement wORK…..” nm=“This Statement wORK…..” nm=“This Statement wORK…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if len(word) > 5: x=x+1 if len(word[x]) > 5: if len(word[x]) > 5: print(word) Q1. Program to display of words whose length is more than 5 Now inside the if condition write the print line only and remove the last print function also, there is no need of print count. print(word[x]) print(word[x])
  • 19. Let Us discuss some of the examples using same format that we discuss to read words Q1. Program to count number of “that” in a string. Q2. Program to count number of words whose first character is VOWEL. Q3. Program to count number of words whose first character is UPPERCASE Q4. Program to count number of words whose first character is LOWERCASE Q5. Program to copy words whose first character is VOWEL in a another variable.
  • 20. word=[‘This’,’Statement’,’that’,’FOR’,’READing’,’WORDS’,’that’,’the’,’String’,’that’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement that…..” nm=“This Statement that…..” nm=“This Statement that…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if word in “that”: x=x+1 if word[x] in “that”: if word[x] in “that”: Inside If condition just check using == “that” to check that word exists Q1. Program to count number of “that” in a string. count=0 count=0 count=0 count=count+1 print(“No of that::”,count) count=count+1 print(“No of that::”,count) count=count+1 print(“No of that::”,count)
  • 21. word=[‘This’,’Statement’,’that’,’FOR’,’READing’,’WORDS’,’that’,’the’,’String’,’that’,’a’,’variable’] for….in for….range while ..loop nm=“This Statement that…..” nm=“This Statement that…..” nm=“This Statement that…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if word “that”: x=x+1 if word[x] “that”: if word[x] “that”: Q1. Program to count number of “that” in a string. count=0 count=0 count=0 count=count+1 print(“No of that::”,count) count=count+1 print(“No of that::”,count) count=count+1 print(“No of that::”,count) == == ==
  • 22. word=[‘This’,’Items’,’that’,’or’,’READing’,’Advance’,’that’,’the’,’String’,’that’,’a’,’variable’] for….in for….range while ..loop nm=“This items that…..” nm=“This items that…..” nm=“This items that…..” for word in nm.split(): word=nm.split() k=len(word) word=nm.split() k=len(word) for x in range(0,k): x=0 while x<k: if word[0] in “AEIOUaeiou”: x=x+1 if word[x][0] in “AEIOUaeiou”: count=0 count=0 count=0 count=count+1 print(“No of vowel:”,count) count=count+1 print(“No of vowel:”,count) count=count+1 print(“No of vowel:”,count) Q2. Program to count number of words whose first character is VOWEL. if word[x][0] in “AEIOUaeiou”: