Answer:
function countEvens(list) {
// IMPLEMENT THIS FUNCTION!
var even = [];
for(var i = 0; i < list.length; i++){
if (list[i] % 2 == 0){
even.push(list[i]);
}
}
return console.log(even)
}
var list = [ 17, 8, 9, 5, 20 ];
var count = countEvens(list);
Explanation:
The programming language used is JavaScript.
An even variable is initialized, to hold the even variables within list.
A FOR loop loop iterates through all the elements in the list, an IF statement is used to check using the modulo division to check if the elements in the list are even.
The even elements are appended to the even list using .push() method.
Finally, the function returns the even list and outputs the list to the log using console.log(even)
.
A list is created and the function is called.
Answer:
Here are the if/elif statements:
if tomatoes == 24: #if farmer sells exactly two dozen tomatoes
watermelons +=4 #farmer receives 4 watermelons
elif tomatoes >= 12: #else farmer sells at least a dozen tomatoes
watermelons +=2 #farmer receives 2 watermelons
else:
tomatoes<12
#On the days that farmer sells less than a dozen tomatoes
apples +=1 #farmer will get a single apple
Explanation:
You can test the working of these if elif statements by this program:
tomatoes = int(input("Enter the amount of tomatoes sold: ")) #prompts user to enter number of tomatoes
watermelons = 0 #initialize watermelons value to 1
apples = 0 #initialize apples value to 1
if tomatoes == 24:
watermelons +=4
elif tomatoes >= 12:
watermelons +=2
else:
tomatoes<12
apples +=1
print("Number of watermelons recieved: ",watermelons) #displays the received number of watermelons
print("Number of apples recieved: ",apples ) #displays the received number of apples
Answer:
In 1904, John Ambrose Fleming invented the first vacuum tube.
Explanation:
Answer:
Relational query language is the language that is used in the queries of the relational databases that has rows and columns in table. The user or client presents a request for gaining the information from the database. The relationships in the database are defined in numerous ways which creates the query.
This language can be procedural form or non-procedural form.The operations performed by this language are communication with the relational database, analyzing the relationships between the entities of database,splitting the request from client and then execution of that request is done by database management system(DBMS), etc.
B- Copyright laws protect original works both online and in print.