Answer:
The answer to this question is given below in the explanation section.
Explanation:
When you use an array in the program, it occupies the memory where to store the data. However, it is noted that the other array cannot store the variable value where the first array has to store its variable value.
however, when you reassign the value their index position of the array, the values are reassigned. But it also depends on the CPU, because sometimes when you release the memory from the array, maybe some other programs get to occupy that location where the first array values were stored.
However, In Java, it is possible that the same int/integer comes at the same spot of the existing integer in an array, then the value at that particular index is reassigned.
Answer:
The solution code is written in Python 3
- count = 0
- sum = 0
-
- num = input("Enter a number: ")
-
- while(num != ''):
- sum += float(num)
- count += 1
- num = input("Enter a number: ")
-
- print("Sum : " + str(sum))
- print("Average: " + str(sum / count))
Explanation:
Firstly, we declare two variables count and sum to hold the number of input number and the total of the input number, respectively (Line 1-2)
Next, we prompt user to input the first number (Line 4). While the num is not ' ' (This means it is not "Enter" key), accumulate the num to sum variable and increment count by one (Line 6-8) and then prompt the user to input the next number (Line 9).
At the end, display the sum and average using print function (Line 11 -12).
Answer:
a group of instructions that can be used to organize a program or perform a repeated task
Explanation:
A function is a group of commands that can be called upon with extra parameters if needed.
Example:
def foo(): #defining this function and naming it foo
return True #what is performed when foo is called on
if foo() == True: #foo() is calling on a function named foo
print('yes')
There are many different ways you can learn how to code, You can use free and paid online courses, Youtube Videos, and Trial and Error. Programming does not come easy and you have to be patient with yourself. Its like learning to drive for the first time, its a little rough but you eventually will catch on and be able to understand what you are doing!
1.) There are many websites that will help teach you different languages like Java, JS, C#, Python, Ruby, Html5, etc.
Here are a few of my favorite websites that helped me.
Code Academy: https://www.codecademy.com/
Khan Academy: <span>https://www.khanacademy.org/
</span>W3Schools (Html Only, Not a Course just useful) http://www.w3schools.com/
I suggest going through those websites, or finding some other websites out there that will help you!
2.) Youtube Videos are perfect for learning specific things in programming! You can learn how to make a calculator, or a website, or anything you'd like! Just simply search for a how-to tutorial and watch the helpful videos! Remember, don't just copy the code.. try and understand it
3.) Trial and Error is one of the best ways you can teach yourself code. It was the best way for me to learn. Everyone learns from their mistakes and you should always try and come up with new things.
Be patient, and enjoy what you are doing! I also suggest working on one language at a time, don't try and learn two or more languages at the same time! Good luck :) Email me at any time if you need any help!