Question
#[]Writeaprogramto: #1)asktheuserforanumberbetween1000and9999 #2)testifthenumbermatchesthefirstlineofanyfilein`files_directory` #3)ifamatchwasfound,printthefilename;otherwise,printnomatchisfound #4)yourcodeshouldhandleexceptionappropriately(i.e.ablankfileorafilecontainingastringinthefirstline) #5)youshoulduse`with`statementforopening/closingfiles #6)makesurethetoruntheenvironmentsetupcodebeforerunningyourownprogram. #testcases: #3932,shouldprintout:Matchfoundin74.txt:3932 #2177,shouldprintout:Matchfoundin27.txt:2177 #4932,shouldprintout:Nomatchingfilesfound
#[]Writeaprogramto:
#1)asktheuserforanumberbetween1000and9999
#2)testifthenumbermatchesthefirstlineofanyfilein`files_directory`
#3)ifamatchwasfound,printthefilename;otherwise,printnomatchisfound
#4)yourcodeshouldhandleexceptionappropriately(i.e.ablankfileorafilecontainingastringinthefirstline)
#5)youshoulduse`with`statementforopening/closingfiles
#6)makesurethetoruntheenvironmentsetupcodebeforerunningyourownprogram.
#testcases:
#3932,shouldprintout:Matchfoundin74.txt:3932
#2177,shouldprintout:Matchfoundin27.txt:2177
#4932,shouldprintout:Nomatchingfilesfound
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started