00:01
Hello students we are given assume that file containing series of integer is named numbers.
00:06
Thth write program that calculates the average of all numbers stored in the file so as a hint we can save our file this is python actually the program must be written in right in python language we need to write that program and we need to save this file and run this file right so basically let's start our program.
00:31
So what we need to do is in program we need to assume file that containing series of numbers.
00:39
So let's start our program with define main.
00:43
So i'm starting the program.
00:45
So basically if i write this program in blue color, right? so basically define definition of main.
00:54
If i write for this.
00:57
So basically first we define our.
00:59
Main function after that we do some exceptional handling number file if i write number file is equals to open first we open that file so what we are doing this exceptional heldings if exceptional cases there then definitely the file is in basically read mode so our file is basically if i write about our file it is numbers dot txt file and we are opening this file in read mode and we are passing this file into that variable number file right as message we can write file open in read mode right now if i write this is try and if i write for this the accept except for exceptional handling so the case of exceptional handling is there if i write exceptional handling exception handling we are doing simultaneously so basically accept i input output error input error if i write with this input output io error as as error generated error generated if i write here, error generated.
02:32
Right now if i write again, so basically this must be written in column and if i write in next step, so basically we need to print in that case file not found, file not found and if i write the message is suited as file not found and error is generated as variable.
02:57
So basically error generated so what we are doing till now that we have just tried to open the file but if a file not found then error is generated so this basically we are doing exceptional handling in exception case the message will be print out but if it is not there then we will get to our else part if it if file is found then else part so we take our variable total equals to zero so exceptional handling is done but if a file found but if a file found then we move to we move to else part to solve else part so in the fire case we need to do exceptional handling first so here another variable if i write is to more explain it is number of number of lines number of lines is equal to zero and we are taking this variable assigning zero here and line variable is equals to numbers numbers dot file numbers dot numbers file so basically this is numbers file numbers file dot read line right now what we are doing is if we are using while case here while line is not equals to this means blank is come then definitely definitely if blank is not come basically means there is a number so basically if i write there is a number if situation is there there is a number found it means we need to we need to increase number of lines if i write we need to increase number of lines so the variable must not be separated we must write according to that number of lines is equal to 0 so we need to increase 1 in that number of line variable so basically this is number of lines so basically if i write here this is number of lines and this is also number of lines is equals to we need to add plus equals to 1 basically it means number of lines equals to number of lines plus one and if i write here this is total equals to so total variable is also added plus equals to end of line so we need to convert our line into integer format and basically basically add in total so basically what does it mean total equals to total plus end of line right so basically in the first case total value zero so other case this value will be stored so basically where is line? so the number that is stored in here...