Now here we have another sample program to calculate the average of numbers in a given list, a very simple program, which uses the input function. Here, in line number 12, we can see n is equal to IMT input within simply brackets enter the number of elements to be entered. And there's an array for i in range zero to n. Every time what we do is we accept the number in the variable element e and e m ind input enter element a dot F and now we have an app and function here. append function, a dot append element. And whatever element is being obtained accordingly, is being stored in a and we are finding finally the sum of A divided by n that is the number of elements and that is how we obtain the round figure of the average of two to two levels of understanding and that is when we execute this program we get the output in this format enter the elements to be entered See I enter three.
So it will ask for the first element say 24 then the other element is 25 and the third element is 26. So, the average is 25.0 and the program finished with exit zero press any key to exit the console. So, this is the first example we have they be abused Functions input function for entering the numbers, then we have defined range and then we have the sum and the round function accordingly to execute the task. Now we have another simple program, which talks about inputting a number and printing it so reverse. Now guys this is a simple program which uses the input function and the while statement. You can check we take a variable and as the number which is integer type, and then we define a variable our EV as zero.
Take a loop while the number is greater than zero digit, we obtain the digit every time we find the modulus of the number So we'll pin the last digit, and then we multiply it with a variable reverse, which is a initial zero. So zero multiplied by the digit by multiply by 10 plus digit will give you the last digit in the first format. And then n is equal to n divided by 10. So the number reduces by one digit, and then the process is on till the number is greater than zero. And then we print reverse of the number is now our EP, and the program is over. Thank you.
So now what I do is I just press f9 or run to it. And here it will ask the number 1234. Suppose I give and I press the enter key. So the reverse of the number is 4321. And the program is over. Thanks.
So this is the execution of the second program. It starts out talks about inputting a number and finding the reverse of the number Ask for length requisite. Now we have another program before you stops about execution is being done using the online Python compiler through online. g db.com. Slash online, underscore Python underscore compiler. Now here, the program is to input a number and print its reverse.
The program asks for a number and accordingly prints the reverse of the same program to input a number and find the sum of its digits is not applicable here. So we'll just edit this as a part of a segment deleted. And then of course, we have n is equal to identity type input Enter a number, a variable to t is equal to zero while the number is greater than zero, the loop will go digit is equal to n percent 10. extracted disappears in the percentage operator, and then we are finding the sum of the digits obtain. Initially the total is zero. So the first time it was larger than the second last, and then accordingly, the first one, and the number is reduced to one digit less. And once this loop is through, we print the total sum of digits is the variable, T, or T. And then we execute the program, we get the first messages into a number, so I just enter a number 12345 is the number.
So the sum of the digits of this number will be one plus two plus three plus four plus five, which is 15. Right? So this is how we get to know about the programming methodology in Python using simple programs. simple logic and simple statements. Here. In this particular program, we are inputting a number and finding its reverse using the while statement.