SlideShare a Scribd company logo
Problems in PYTHON3.5 1. Define a function sumOfDigits that has one parameter of type
string. The function should return the sum of the digits in the string. Do not treat multiple digit
string as one number – “2014” should be treated as 4 different digits of 2, 0, 1, 4. The function
should return 17 for the string “Today’s date is 09/01/2014”. Then write a main program that
asks a user to enter a sentence and then displays the sum of digits that are in the sentence by
using the function, sumOfDigits. The function sumOfDigits should only do what’s asked to do. It
should not do any additional tasks such as print or input!!!
Solution
Before implementing the function, we need to check whether the integer comes into the string or
not.
To do that there is an in-built function in Python, isdigit() which checks whether the input is the
integer
or some other character.
def sumOfDigits(input_str):
summation = 0
for number in list(input_str):
if number.isdigit():
summation += int(number)
return summation
Hence, this will loop through the entire string and check for each of them whether it is integer or
some other character.For all the integer it is summing up the values and returning it at the end of
the function definition.

More Related Content

Similar to Problems in PYTHON3.5 1. Define a function sumOfDigits that has one .pdf

Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
Inzamam Baig
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
SAKSHIGAWADE2
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
Mohammed Saleh
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
 
Review Python
Review PythonReview Python
Review Python
ManishTiwari326
 
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in cDavid Livingston J
 
Function in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programmingFunction in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programming
estorebackupr
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in cDavid Livingston J
 
P3
P3P3
P3
lksoo
 
Updated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptxUpdated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptx
momina273888
 
Updated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptxUpdated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptx
CruiseCH
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
ziyadaslanbey
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Devry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functionsDevry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functions
noahjamessss
 
Devry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functionsDevry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functions
govendaagoovenda
 
03 Variables - Chang.pptx
03 Variables - Chang.pptx03 Variables - Chang.pptx
03 Variables - Chang.pptx
Dileep804402
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
adihartanto7
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharp
Daniele Pozzobon
 

Similar to Problems in PYTHON3.5 1. Define a function sumOfDigits that has one .pdf (20)

Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
 
Review Python
Review PythonReview Python
Review Python
 
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in c
 
Function in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programmingFunction in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programming
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in c
 
P3
P3P3
P3
 
Updated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptxUpdated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptx
 
Updated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptxUpdated Week 06 and 07 Functions In Python.pptx
Updated Week 06 and 07 Functions In Python.pptx
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Devry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functionsDevry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functions
 
Devry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functionsDevry cis-170-c-i lab-4-of-7-functions
Devry cis-170-c-i lab-4-of-7-functions
 
03 Variables - Chang.pptx
03 Variables - Chang.pptx03 Variables - Chang.pptx
03 Variables - Chang.pptx
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharp
 

More from infoeyecare

All fungi have tiny tube-like structures call hyphae. One is labeled .pdf
All fungi have tiny tube-like structures call hyphae. One is labeled .pdfAll fungi have tiny tube-like structures call hyphae. One is labeled .pdf
All fungi have tiny tube-like structures call hyphae. One is labeled .pdf
infoeyecare
 
15. Let’s say you are systems administrator for a hospital’s network.pdf
15. Let’s say you are systems administrator for a hospital’s network.pdf15. Let’s say you are systems administrator for a hospital’s network.pdf
15. Let’s say you are systems administrator for a hospital’s network.pdf
infoeyecare
 
What would the predicted result be if Griffith injected mice with a .pdf
What would the predicted result be if Griffith injected mice with a .pdfWhat would the predicted result be if Griffith injected mice with a .pdf
What would the predicted result be if Griffith injected mice with a .pdf
infoeyecare
 
Write a function called myfind that will search for a key in a vecto.pdf
Write a function called myfind that will search for a key in a vecto.pdfWrite a function called myfind that will search for a key in a vecto.pdf
Write a function called myfind that will search for a key in a vecto.pdf
infoeyecare
 
wright Mills proposed that sociologists could explain individual beha.pdf
wright Mills proposed that sociologists could explain individual beha.pdfwright Mills proposed that sociologists could explain individual beha.pdf
wright Mills proposed that sociologists could explain individual beha.pdf
infoeyecare
 
Why are General, Special Revenue, and other governmental (expendable).pdf
Why are General, Special Revenue, and other governmental (expendable).pdfWhy are General, Special Revenue, and other governmental (expendable).pdf
Why are General, Special Revenue, and other governmental (expendable).pdf
infoeyecare
 
Which functions of a cell membrane would be compromised if the membr.pdf
Which functions of a cell membrane would be compromised if the membr.pdfWhich functions of a cell membrane would be compromised if the membr.pdf
Which functions of a cell membrane would be compromised if the membr.pdf
infoeyecare
 
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdfWhat is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
infoeyecare
 
What is ransomware How can these cyber-attacks result in data loss.pdf
What is ransomware How can these cyber-attacks result in data loss.pdfWhat is ransomware How can these cyber-attacks result in data loss.pdf
What is ransomware How can these cyber-attacks result in data loss.pdf
infoeyecare
 
What are the 3 ways a Java method must match with its definition and.pdf
What are the 3 ways a Java method must match with its definition and.pdfWhat are the 3 ways a Java method must match with its definition and.pdf
What are the 3 ways a Java method must match with its definition and.pdf
infoeyecare
 
Using the Internet, compare and contrast two commercially available .pdf
Using the Internet, compare and contrast two commercially available .pdfUsing the Internet, compare and contrast two commercially available .pdf
Using the Internet, compare and contrast two commercially available .pdf
infoeyecare
 
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdfuetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
infoeyecare
 
The starship Epidemiology Team has cone many missions exploring the u.pdf
The starship Epidemiology Team has cone many missions exploring the u.pdfThe starship Epidemiology Team has cone many missions exploring the u.pdf
The starship Epidemiology Team has cone many missions exploring the u.pdf
infoeyecare
 
Question 3)Perform a regression analysis using compa as the depend.pdf
Question 3)Perform a regression analysis using compa as the depend.pdfQuestion 3)Perform a regression analysis using compa as the depend.pdf
Question 3)Perform a regression analysis using compa as the depend.pdf
infoeyecare
 
Only a very small percentage of organisms actually fossilize. Based o.pdf
Only a very small percentage of organisms actually fossilize. Based o.pdfOnly a very small percentage of organisms actually fossilize. Based o.pdf
Only a very small percentage of organisms actually fossilize. Based o.pdf
infoeyecare
 
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdfpackage lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
infoeyecare
 
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdfOdin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
infoeyecare
 
Many new species of desert have arisen from a population which was .pdf
Many new species of desert  have arisen from a  population which was .pdfMany new species of desert  have arisen from a  population which was .pdf
Many new species of desert have arisen from a population which was .pdf
infoeyecare
 
List and analyze some of the most salient social factors of group un.pdf
List and analyze some of the most salient social factors of group un.pdfList and analyze some of the most salient social factors of group un.pdf
List and analyze some of the most salient social factors of group un.pdf
infoeyecare
 
J. A. Moore investigated the inheritance of spotting patterns in leop.pdf
J. A. Moore investigated the inheritance of spotting patterns in leop.pdfJ. A. Moore investigated the inheritance of spotting patterns in leop.pdf
J. A. Moore investigated the inheritance of spotting patterns in leop.pdf
infoeyecare
 

More from infoeyecare (20)

All fungi have tiny tube-like structures call hyphae. One is labeled .pdf
All fungi have tiny tube-like structures call hyphae. One is labeled .pdfAll fungi have tiny tube-like structures call hyphae. One is labeled .pdf
All fungi have tiny tube-like structures call hyphae. One is labeled .pdf
 
15. Let’s say you are systems administrator for a hospital’s network.pdf
15. Let’s say you are systems administrator for a hospital’s network.pdf15. Let’s say you are systems administrator for a hospital’s network.pdf
15. Let’s say you are systems administrator for a hospital’s network.pdf
 
What would the predicted result be if Griffith injected mice with a .pdf
What would the predicted result be if Griffith injected mice with a .pdfWhat would the predicted result be if Griffith injected mice with a .pdf
What would the predicted result be if Griffith injected mice with a .pdf
 
Write a function called myfind that will search for a key in a vecto.pdf
Write a function called myfind that will search for a key in a vecto.pdfWrite a function called myfind that will search for a key in a vecto.pdf
Write a function called myfind that will search for a key in a vecto.pdf
 
wright Mills proposed that sociologists could explain individual beha.pdf
wright Mills proposed that sociologists could explain individual beha.pdfwright Mills proposed that sociologists could explain individual beha.pdf
wright Mills proposed that sociologists could explain individual beha.pdf
 
Why are General, Special Revenue, and other governmental (expendable).pdf
Why are General, Special Revenue, and other governmental (expendable).pdfWhy are General, Special Revenue, and other governmental (expendable).pdf
Why are General, Special Revenue, and other governmental (expendable).pdf
 
Which functions of a cell membrane would be compromised if the membr.pdf
Which functions of a cell membrane would be compromised if the membr.pdfWhich functions of a cell membrane would be compromised if the membr.pdf
Which functions of a cell membrane would be compromised if the membr.pdf
 
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdfWhat is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
What is the state of water at 200 kPa and 250oCQuestion 7 options.pdf
 
What is ransomware How can these cyber-attacks result in data loss.pdf
What is ransomware How can these cyber-attacks result in data loss.pdfWhat is ransomware How can these cyber-attacks result in data loss.pdf
What is ransomware How can these cyber-attacks result in data loss.pdf
 
What are the 3 ways a Java method must match with its definition and.pdf
What are the 3 ways a Java method must match with its definition and.pdfWhat are the 3 ways a Java method must match with its definition and.pdf
What are the 3 ways a Java method must match with its definition and.pdf
 
Using the Internet, compare and contrast two commercially available .pdf
Using the Internet, compare and contrast two commercially available .pdfUsing the Internet, compare and contrast two commercially available .pdf
Using the Internet, compare and contrast two commercially available .pdf
 
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdfuetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
uetator Periodic Table Question 6 of 30 Incorrect Incorrect DA Saplin.pdf
 
The starship Epidemiology Team has cone many missions exploring the u.pdf
The starship Epidemiology Team has cone many missions exploring the u.pdfThe starship Epidemiology Team has cone many missions exploring the u.pdf
The starship Epidemiology Team has cone many missions exploring the u.pdf
 
Question 3)Perform a regression analysis using compa as the depend.pdf
Question 3)Perform a regression analysis using compa as the depend.pdfQuestion 3)Perform a regression analysis using compa as the depend.pdf
Question 3)Perform a regression analysis using compa as the depend.pdf
 
Only a very small percentage of organisms actually fossilize. Based o.pdf
Only a very small percentage of organisms actually fossilize. Based o.pdfOnly a very small percentage of organisms actually fossilize. Based o.pdf
Only a very small percentage of organisms actually fossilize. Based o.pdf
 
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdfpackage lab7; import java.util.Scanner; Sammy Student, Program.pdf
package lab7; import java.util.Scanner; Sammy Student, Program.pdf
 
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdfOdin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
Odin and Zeus travel to the outermost reaches of our galaxy using wa.pdf
 
Many new species of desert have arisen from a population which was .pdf
Many new species of desert  have arisen from a  population which was .pdfMany new species of desert  have arisen from a  population which was .pdf
Many new species of desert have arisen from a population which was .pdf
 
List and analyze some of the most salient social factors of group un.pdf
List and analyze some of the most salient social factors of group un.pdfList and analyze some of the most salient social factors of group un.pdf
List and analyze some of the most salient social factors of group un.pdf
 
J. A. Moore investigated the inheritance of spotting patterns in leop.pdf
J. A. Moore investigated the inheritance of spotting patterns in leop.pdfJ. A. Moore investigated the inheritance of spotting patterns in leop.pdf
J. A. Moore investigated the inheritance of spotting patterns in leop.pdf
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
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
 
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
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
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
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
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
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
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...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
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 ...
 
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
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
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
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 

Problems in PYTHON3.5 1. Define a function sumOfDigits that has one .pdf

  • 1. Problems in PYTHON3.5 1. Define a function sumOfDigits that has one parameter of type string. The function should return the sum of the digits in the string. Do not treat multiple digit string as one number – “2014” should be treated as 4 different digits of 2, 0, 1, 4. The function should return 17 for the string “Today’s date is 09/01/2014”. Then write a main program that asks a user to enter a sentence and then displays the sum of digits that are in the sentence by using the function, sumOfDigits. The function sumOfDigits should only do what’s asked to do. It should not do any additional tasks such as print or input!!! Solution Before implementing the function, we need to check whether the integer comes into the string or not. To do that there is an in-built function in Python, isdigit() which checks whether the input is the integer or some other character. def sumOfDigits(input_str): summation = 0 for number in list(input_str): if number.isdigit(): summation += int(number) return summation Hence, this will loop through the entire string and check for each of them whether it is integer or some other character.For all the integer it is summing up the values and returning it at the end of the function definition.