Good evening all!
We all know that python is a scripting language. It is a scripting language because it's source code is interpreted to an object code by an a program translator known as Interpreter!!
According to Wikipedia, as edited January 17 (2022),
Python is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects. source.
With this little explanation of python, I believe that you have had the basic knowledge of what python is all about! So coming to what I have for you today which encompasses the following Programming topics:
- How to Calculate the Sum and Average of a given list. And
- How to Calculate Sum and Average using while loop
From this sequence, hence, I will proceed with the first Programming topic.
1. How to Calculate the Sum and Average of a given list
I will guide this with a screenshot. I have an Android python IDE called "Pyroid" which is used to run python source codes on Android mobile phones!
Source Code
Output
If you deem closely to the source code above, you will notice that there are 14 lines of codes, but if you exclude the whitespaces, it becomes 7 lines of codes.
Don't understand the program? Don't worry, make some research about python programming language and you will understand more!
If you look up, you will see the output of the source code. Line 5 is a for loop that executes untill a certain condition is met! Line 12 and 14 printed the result/output to the screen so that the user can see it.
2. How to Calculate Sum and Average using while loop
While loop is one of the control structures we have in Programming entirely. Others include; for loop, and do while. We all know what is sum and what is Average already!
Source Code
Output
From the source code and the output above, we can see that line 7 performs the function of executing the statement untill all the sum has been calculated.
Yay! 🤗
Your content has been boosted with Ecency Points
Use Ecency daily to boost your growth on platform!
Support Ecency
Vote for new Proposal
Delegate HP and earn more, by @anyiglobal.
Congratulations @anyiglobal! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):
Your next target is to reach 100 upvotes.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out the last post from @hivebuzz:
Support the HiveBuzz project. Vote for our proposal!