Answer:
I dont know about 1800 words but I sure can tell you abit about array
Explanation: Array in simple sense refers to a collection of similar data. It holds data which is homogeneous in nature, meaning they are all alike. The use of array provide a lot of advantages in the fields of computer programming. When you declare a variable for an array, you can store as much data as you wish in the same variable without having to declare many variables. A 2X2 dimensional array can also be used in programming which represents matrices as well. The search process in an array too is really convenient and time saving. Also in an array, accessing an element is very easy by using the index number.
Answer:
The solution is written using Python as it has a simple syntax.
- def getHighScores(gameScores, minScore):
- meetsThreshold = []
- for score in gameScores:
- if(score > minScore):
- meetsThreshold.append(score)
- return meetsThreshold
- gameScores = [2, 5, 7, 6, 1, 9, 1]
- minScore = 5
- highScores = getHighScores(gameScores, minScore)
- print(highScores)
Explanation:
Line 1-8
- Create a function and name it as <em>getHighScores</em> which accepts two values, <em>gameScores</em> and <em>minScore</em>. (Line 1)
- Create an empty list/array and assign it to variable <em>meetsThreshold</em>. (Line 2)
- Create a for loop to iterate through each of the score in the <em>gameScores</em> (Line 4)
- Set a condition if the current score is bigger than the <em>minScore</em>, add the score into the <em>meetsThreshold</em> list (Line 5-6)
- Return <em>meetsThreshold</em> list as the output
Line 11-12
- create a random list of <em>gameScores</em> (Line 11)
- Set the minimum score to 5 (Line 12)
Line 13-14
- Call the function <em>getHighScores()</em> and pass the<em> gameScores</em> and <em>minScore </em>as the arguments. The codes within the function <em>getHighScores()</em> will run and return the <em>meetsThreshold </em>list and assign it to <em>highScores.</em> (Line 13)
- Display <em>highScores</em> using built-in function print().
4. Only (ii)
<u>Explanation:</u>
The declaration of the array can be of two types:
1. int a[100];
2. int[] a = new int[100];
The general thing about an array is that whenever we want to undergo traversal in an array, we always have to start from the 0th position as the size of the array may be a whole number (let us say 10). So, to undergo traversal in an array, we start from 0 to n-1 (in this case 9) such that it covers the size of the array.
The size of an array can be finite or infinite. The general rule is it starts from 0 to n-1 where n is the size of the array. In the above example, the range of the index of the array will be 0 through 100 and not 1 through 100.
Answer:
an error message
Explanation:
The return value is the value which is sent back by the function to a place in the code from where the
was called from. Its main work is to return a value form the function.
In the context, the form of "(symbol-length? 'James)" in Scheme will return the value --- ' an error message'.