SlideShare a Scribd company logo
1 of 2
Download to read offline
Using Python convert the following to a while-loop construct. You need not use all the defined
variables.
def main ():
sum = 0
number_1 = input(“Enter a number”)
number_2 = input(“Enter a number”)
number_3 = input(“Enter a number”)
sum = number_1+number_2+number_3
print(sum)
main()
Solution
Answer:
def main ():
sum = 0
i = 0
while i < 3:
sum = sum + input("Enter a number")
i = i + 1
print(sum)
main();
Output:
sh-4.3$ python
main.py
Enter a
number2
Enter a
number3
Enter a
number4
9

More Related Content

More from arjunstores123

How does multicore differ from a classic multiprocessing environment.pdf
How does multicore differ from a classic multiprocessing environment.pdfHow does multicore differ from a classic multiprocessing environment.pdf
How does multicore differ from a classic multiprocessing environment.pdfarjunstores123
 
How the non-dense index worksHow the non-dense index works.pdf
How the non-dense index worksHow the non-dense index works.pdfHow the non-dense index worksHow the non-dense index works.pdf
How the non-dense index worksHow the non-dense index works.pdfarjunstores123
 
Given below is the response of several types of temperature sensors. .pdf
Given below is the response of several types of temperature sensors. .pdfGiven below is the response of several types of temperature sensors. .pdf
Given below is the response of several types of temperature sensors. .pdfarjunstores123
 
Genetic recombination can occur in many different stages. Identify t.pdf
Genetic recombination can occur in many different stages. Identify t.pdfGenetic recombination can occur in many different stages. Identify t.pdf
Genetic recombination can occur in many different stages. Identify t.pdfarjunstores123
 
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdf
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdfFor every one NADH molecule oxidized at complex I, how many TOTAL hy.pdf
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdfarjunstores123
 
Find the domain of the function. (Enter your answer using interval no.pdf
Find the domain of the function. (Enter your answer using interval no.pdfFind the domain of the function. (Enter your answer using interval no.pdf
Find the domain of the function. (Enter your answer using interval no.pdfarjunstores123
 
explain as specifically as possible how each of the following helps .pdf
explain as specifically as possible how each of the following helps .pdfexplain as specifically as possible how each of the following helps .pdf
explain as specifically as possible how each of the following helps .pdfarjunstores123
 
Each of the following lymphatic structures in the correct category ba.pdf
Each of the following lymphatic structures in the correct category ba.pdfEach of the following lymphatic structures in the correct category ba.pdf
Each of the following lymphatic structures in the correct category ba.pdfarjunstores123
 
Answer the following questions from the Article belowExercise #1..pdf
Answer the following questions from the Article belowExercise #1..pdfAnswer the following questions from the Article belowExercise #1..pdf
Answer the following questions from the Article belowExercise #1..pdfarjunstores123
 
All answers are in the form of TrueFalse with a explantion as to wh.pdf
All answers are in the form of TrueFalse with a explantion as to wh.pdfAll answers are in the form of TrueFalse with a explantion as to wh.pdf
All answers are in the form of TrueFalse with a explantion as to wh.pdfarjunstores123
 
Consider miRNA target sites, How do these compare to transcription fa.pdf
Consider miRNA target sites, How do these compare to transcription fa.pdfConsider miRNA target sites, How do these compare to transcription fa.pdf
Consider miRNA target sites, How do these compare to transcription fa.pdfarjunstores123
 
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdf
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdfAnaerobic Respiration & Fermentation (Microbiology)What are the bu.pdf
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdfarjunstores123
 
4. Pick out any text-mining tool that impressed you the most and dis.pdf
4. Pick out any text-mining tool that impressed you the most and dis.pdf4. Pick out any text-mining tool that impressed you the most and dis.pdf
4. Pick out any text-mining tool that impressed you the most and dis.pdfarjunstores123
 
At the end of this lecture you should be able to Compare and contrast.pdf
At the end of this lecture you should be able to Compare and contrast.pdfAt the end of this lecture you should be able to Compare and contrast.pdf
At the end of this lecture you should be able to Compare and contrast.pdfarjunstores123
 
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdf
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdfCase Study Amanda is a 22 year old newly qualified teacher who lov.pdf
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdfarjunstores123
 
Write an equation for the function graphed. Show the work to find th.pdf
Write an equation for the function graphed. Show the work to find th.pdfWrite an equation for the function graphed. Show the work to find th.pdf
Write an equation for the function graphed. Show the work to find th.pdfarjunstores123
 
Why does a RNA virus carry essential enzymes within its particles,.pdf
Why does a RNA virus carry essential enzymes within its particles,.pdfWhy does a RNA virus carry essential enzymes within its particles,.pdf
Why does a RNA virus carry essential enzymes within its particles,.pdfarjunstores123
 
Why is Tyrosine more acidic than Serine, even though they both are a.pdf
Why is Tyrosine more acidic than Serine, even though they both are a.pdfWhy is Tyrosine more acidic than Serine, even though they both are a.pdf
Why is Tyrosine more acidic than Serine, even though they both are a.pdfarjunstores123
 
which particular factors that earlier may have been somewhat weak.pdf
which particular factors that earlier may have been somewhat weak.pdfwhich particular factors that earlier may have been somewhat weak.pdf
which particular factors that earlier may have been somewhat weak.pdfarjunstores123
 
Which of the following are partial differential equations I. y + y.pdf
Which of the following are partial differential equations I. y + y.pdfWhich of the following are partial differential equations I. y + y.pdf
Which of the following are partial differential equations I. y + y.pdfarjunstores123
 

More from arjunstores123 (20)

How does multicore differ from a classic multiprocessing environment.pdf
How does multicore differ from a classic multiprocessing environment.pdfHow does multicore differ from a classic multiprocessing environment.pdf
How does multicore differ from a classic multiprocessing environment.pdf
 
How the non-dense index worksHow the non-dense index works.pdf
How the non-dense index worksHow the non-dense index works.pdfHow the non-dense index worksHow the non-dense index works.pdf
How the non-dense index worksHow the non-dense index works.pdf
 
Given below is the response of several types of temperature sensors. .pdf
Given below is the response of several types of temperature sensors. .pdfGiven below is the response of several types of temperature sensors. .pdf
Given below is the response of several types of temperature sensors. .pdf
 
Genetic recombination can occur in many different stages. Identify t.pdf
Genetic recombination can occur in many different stages. Identify t.pdfGenetic recombination can occur in many different stages. Identify t.pdf
Genetic recombination can occur in many different stages. Identify t.pdf
 
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdf
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdfFor every one NADH molecule oxidized at complex I, how many TOTAL hy.pdf
For every one NADH molecule oxidized at complex I, how many TOTAL hy.pdf
 
Find the domain of the function. (Enter your answer using interval no.pdf
Find the domain of the function. (Enter your answer using interval no.pdfFind the domain of the function. (Enter your answer using interval no.pdf
Find the domain of the function. (Enter your answer using interval no.pdf
 
explain as specifically as possible how each of the following helps .pdf
explain as specifically as possible how each of the following helps .pdfexplain as specifically as possible how each of the following helps .pdf
explain as specifically as possible how each of the following helps .pdf
 
Each of the following lymphatic structures in the correct category ba.pdf
Each of the following lymphatic structures in the correct category ba.pdfEach of the following lymphatic structures in the correct category ba.pdf
Each of the following lymphatic structures in the correct category ba.pdf
 
Answer the following questions from the Article belowExercise #1..pdf
Answer the following questions from the Article belowExercise #1..pdfAnswer the following questions from the Article belowExercise #1..pdf
Answer the following questions from the Article belowExercise #1..pdf
 
All answers are in the form of TrueFalse with a explantion as to wh.pdf
All answers are in the form of TrueFalse with a explantion as to wh.pdfAll answers are in the form of TrueFalse with a explantion as to wh.pdf
All answers are in the form of TrueFalse with a explantion as to wh.pdf
 
Consider miRNA target sites, How do these compare to transcription fa.pdf
Consider miRNA target sites, How do these compare to transcription fa.pdfConsider miRNA target sites, How do these compare to transcription fa.pdf
Consider miRNA target sites, How do these compare to transcription fa.pdf
 
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdf
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdfAnaerobic Respiration & Fermentation (Microbiology)What are the bu.pdf
Anaerobic Respiration & Fermentation (Microbiology)What are the bu.pdf
 
4. Pick out any text-mining tool that impressed you the most and dis.pdf
4. Pick out any text-mining tool that impressed you the most and dis.pdf4. Pick out any text-mining tool that impressed you the most and dis.pdf
4. Pick out any text-mining tool that impressed you the most and dis.pdf
 
At the end of this lecture you should be able to Compare and contrast.pdf
At the end of this lecture you should be able to Compare and contrast.pdfAt the end of this lecture you should be able to Compare and contrast.pdf
At the end of this lecture you should be able to Compare and contrast.pdf
 
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdf
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdfCase Study Amanda is a 22 year old newly qualified teacher who lov.pdf
Case Study Amanda is a 22 year old newly qualified teacher who lov.pdf
 
Write an equation for the function graphed. Show the work to find th.pdf
Write an equation for the function graphed. Show the work to find th.pdfWrite an equation for the function graphed. Show the work to find th.pdf
Write an equation for the function graphed. Show the work to find th.pdf
 
Why does a RNA virus carry essential enzymes within its particles,.pdf
Why does a RNA virus carry essential enzymes within its particles,.pdfWhy does a RNA virus carry essential enzymes within its particles,.pdf
Why does a RNA virus carry essential enzymes within its particles,.pdf
 
Why is Tyrosine more acidic than Serine, even though they both are a.pdf
Why is Tyrosine more acidic than Serine, even though they both are a.pdfWhy is Tyrosine more acidic than Serine, even though they both are a.pdf
Why is Tyrosine more acidic than Serine, even though they both are a.pdf
 
which particular factors that earlier may have been somewhat weak.pdf
which particular factors that earlier may have been somewhat weak.pdfwhich particular factors that earlier may have been somewhat weak.pdf
which particular factors that earlier may have been somewhat weak.pdf
 
Which of the following are partial differential equations I. y + y.pdf
Which of the following are partial differential equations I. y + y.pdfWhich of the following are partial differential equations I. y + y.pdf
Which of the following are partial differential equations I. y + y.pdf
 

Recently uploaded

ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 

Using Python convert the following to a while-loop construct. You ne.pdf

  • 1. Using Python convert the following to a while-loop construct. You need not use all the defined variables. def main (): sum = 0 number_1 = input(“Enter a number”) number_2 = input(“Enter a number”) number_3 = input(“Enter a number”) sum = number_1+number_2+number_3 print(sum) main() Solution Answer: def main (): sum = 0 i = 0 while i < 3: sum = sum + input("Enter a number") i = i + 1 print(sum) main(); Output: sh-4.3$ python main.py Enter a number2 Enter a number3 Enter a number4
  • 2. 9