SlideShare a Scribd company logo
1 of 2
Download to read offline
14. Suppose I have collected the names of people in several separate files based on their starting
letter. The names in the first file begin with A through G, the names in the second file begin with
H through N, the names in the third file beginning with O through T, and the names in the fourth
file contain names beginning with U through Z. None of the files are sorted. instead, the names
that appear in each file occur in any order. Describe in detail how I could take advantage of
multithreading to create one sorted list of all the names. Make sure you include details such as
what your Thread class would do and what your main class that uses the Threads would do. (3
points)
Solution
We can slice strings with negative indexes as well. This IDLE transcript should clarify the rules
for slicing where both indexes are specified:
>>> word = "PYTHONISCOOL"
>>> print(word[2:7])
THONI
>>> print(word[6:6])
>>> print(word[4:2])
>>> print(word[5:11])
NISCOO
>>> print(word[8:12])
COOL
>>>
>>> print(word[-7:-2])
NISCO
>>> print(word[-9:8])
HONIS
>>> print(word[-3:-7])
>>>
Notice if you attempt to slice a string where the starting index refers to a position that occurs at
or after the ending index, the slice is the empty string, containing no characters.
A string can also be sliced using only one index. If only one index is given, Python must know if
it’s the start or end of the slice. It assumes that the omitted index must refer to the beginning or
end of the string, accordingly. These examples should clarify slicing using only one index:
>>> print(word[8:])
COOL
>>> print(word[-6:])
ISCOOL
>>> print(word[:6])
PYTHON
>>> print(word[:-4])
PYTHONIS

More Related Content

More from mumnesh

For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdfFor Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
mumnesh
 
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
Discuss the dangers associated with hydrogen sulfide in the petro.pdfDiscuss the dangers associated with hydrogen sulfide in the petro.pdf
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
mumnesh
 
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
CommunicationsSystems have four basic properties (holism, equi-fi.pdfCommunicationsSystems have four basic properties (holism, equi-fi.pdf
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
mumnesh
 
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdfAbraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
mumnesh
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf
mumnesh
 
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdfYou are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
mumnesh
 
Which of the following statements are true I. The space P_2 is a sub.pdf
Which of the following statements are true I. The space P_2 is a sub.pdfWhich of the following statements are true I. The space P_2 is a sub.pdf
Which of the following statements are true I. The space P_2 is a sub.pdf
mumnesh
 

More from mumnesh (20)

For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdfFor Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
 
For analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdf
For analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdfFor analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdf
For analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdf
 
Fill in the blank. A contingency table relates only continuous rando.pdf
Fill in the blank. A contingency table relates  only continuous rando.pdfFill in the blank. A contingency table relates  only continuous rando.pdf
Fill in the blank. A contingency table relates only continuous rando.pdf
 
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
Discuss the dangers associated with hydrogen sulfide in the petro.pdfDiscuss the dangers associated with hydrogen sulfide in the petro.pdf
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
 
Complete the following paragraph to describe the various reproductive.pdf
Complete the following paragraph to describe the various reproductive.pdfComplete the following paragraph to describe the various reproductive.pdf
Complete the following paragraph to describe the various reproductive.pdf
 
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
CommunicationsSystems have four basic properties (holism, equi-fi.pdfCommunicationsSystems have four basic properties (holism, equi-fi.pdf
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
 
Based on your reading of the GCU introduction and the textbooks, wha.pdf
Based on your reading of the GCU introduction and the textbooks, wha.pdfBased on your reading of the GCU introduction and the textbooks, wha.pdf
Based on your reading of the GCU introduction and the textbooks, wha.pdf
 
Answer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdf
Answer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdfAnswer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdf
Answer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdf
 
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdfAbraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
 
29. This figure shows the principal coronary blood vessels. Which one.pdf
29. This figure shows the principal coronary blood vessels. Which one.pdf29. This figure shows the principal coronary blood vessels. Which one.pdf
29. This figure shows the principal coronary blood vessels. Which one.pdf
 
4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf4. The size of instructions can be fixed or variable. What are advant.pdf
4. The size of instructions can be fixed or variable. What are advant.pdf
 
13. What is the difference between post-consumer recycled materials a.pdf
13. What is the difference between post-consumer recycled materials a.pdf13. What is the difference between post-consumer recycled materials a.pdf
13. What is the difference between post-consumer recycled materials a.pdf
 
1a.MinC and MinD promote even bacterial cell division by    suppre.pdf
1a.MinC and MinD promote even bacterial cell division by    suppre.pdf1a.MinC and MinD promote even bacterial cell division by    suppre.pdf
1a.MinC and MinD promote even bacterial cell division by    suppre.pdf
 
1.87 points PA3-4 Part 2 2. Prepare journal entries to record the Sep.pdf
1.87 points PA3-4 Part 2 2. Prepare journal entries to record the Sep.pdf1.87 points PA3-4 Part 2 2. Prepare journal entries to record the Sep.pdf
1.87 points PA3-4 Part 2 2. Prepare journal entries to record the Sep.pdf
 
1.Explain (in your own words) seven good reasons for freezing cell l.pdf
1.Explain (in your own words) seven good reasons for freezing cell l.pdf1.Explain (in your own words) seven good reasons for freezing cell l.pdf
1.Explain (in your own words) seven good reasons for freezing cell l.pdf
 
What is the shared ancestral character of all the organismsSh.pdf
What is the shared ancestral character of all the organismsSh.pdfWhat is the shared ancestral character of all the organismsSh.pdf
What is the shared ancestral character of all the organismsSh.pdf
 
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdfYou are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
You are the CEO of Bonner, a U.S.-based farm equipment corporation. .pdf
 
Which of the following statements are true I. The space P_2 is a sub.pdf
Which of the following statements are true I. The space P_2 is a sub.pdfWhich of the following statements are true I. The space P_2 is a sub.pdf
Which of the following statements are true I. The space P_2 is a sub.pdf
 
why are indirect proofs not taught in schools anymoreSolution .pdf
why are indirect proofs not taught in schools anymoreSolution  .pdfwhy are indirect proofs not taught in schools anymoreSolution  .pdf
why are indirect proofs not taught in schools anymoreSolution .pdf
 
When Magnesium Chloride is dissolved in water, which part(s) of the .pdf
When Magnesium Chloride is dissolved in water, which part(s) of the .pdfWhen Magnesium Chloride is dissolved in water, which part(s) of the .pdf
When Magnesium Chloride is dissolved in water, which part(s) of the .pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
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
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
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)
 
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
 
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...
 
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...
 
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Ư...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
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
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
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
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
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
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 

14. Suppose I have collected the names of people in several separate.pdf

  • 1. 14. Suppose I have collected the names of people in several separate files based on their starting letter. The names in the first file begin with A through G, the names in the second file begin with H through N, the names in the third file beginning with O through T, and the names in the fourth file contain names beginning with U through Z. None of the files are sorted. instead, the names that appear in each file occur in any order. Describe in detail how I could take advantage of multithreading to create one sorted list of all the names. Make sure you include details such as what your Thread class would do and what your main class that uses the Threads would do. (3 points) Solution We can slice strings with negative indexes as well. This IDLE transcript should clarify the rules for slicing where both indexes are specified: >>> word = "PYTHONISCOOL" >>> print(word[2:7]) THONI >>> print(word[6:6]) >>> print(word[4:2]) >>> print(word[5:11]) NISCOO >>> print(word[8:12]) COOL >>> >>> print(word[-7:-2]) NISCO >>> print(word[-9:8]) HONIS >>> print(word[-3:-7]) >>> Notice if you attempt to slice a string where the starting index refers to a position that occurs at or after the ending index, the slice is the empty string, containing no characters. A string can also be sliced using only one index. If only one index is given, Python must know if it’s the start or end of the slice. It assumes that the omitted index must refer to the beginning or end of the string, accordingly. These examples should clarify slicing using only one index: >>> print(word[8:])